1
我正在使用jQuery來獲取表單的值,並進行AJAX POST調用並將值發佈到.php文件,該文件將值處理到數據庫中。爲什麼jQuery沒有得到這個值?
每當我試着用alert()
測試,如果我得到的價值,一切正常,除了股票價值......我無法找到我在做什麼錯..
的jQuery:
var title = $("#title").val();
var text = $("#text").val();
var summary = $("#description").val();
var keywords = $("#keywords").val();
var price = $("#price").val();
var stock = $("#stock").val();
var brand = $("#brand").val();
var product = product;
alert(title);
alert(stock);
形式:
<form class="form-horizontal form-inline">
<div class="form-group">
<label class="control-label col-sm-3" for="title">Product:</label>
<input type="text" class="form-control" id="title" name="title" placeholder="Enter new title">
</div>
<div class="form-group">
<label class="control-label col-sm-3" for="price">Price:</label>
<input type="text" class="form-control" id="price" name="price" placeholder="Enter new price">
</div>
<div class="form-group">
<label class="control-label col-sm-3" for="stock">Stock:</label>
<input type="text" class="form-control" id="stock" name="stock" placeholder="Enter new stock">
</div>
<div class='form-group'>
<label class="control-label col-sm-3" for="text">Text:</label>
<textarea class='form-control' rows='5' id='text' name='text' placeholder='Enter new text'></textarea>
</div>
<div class="form-group">
<label class="control-label col-sm-3" for="description">Description:</label>
<input type="text" class="form-control" id="description" name="description" placeholder="Enter new description">
</div>
<div class="form-group">
<label class="control-label col-sm-3" for="brand">Brand:</label>
<input type="text" class="form-control" id="brand" name="brand" placeholder="Enter new brand">
</div>
<div class="form-group">
<label class="control-label col-sm-3" for="keywords">Keywords:</label>
<input type="text" class="form-control" id="keywords" name="keywords" placeholder="Enter new keywords">
</div>
<a href="#" id="updateProductRecord" pid="<?php echo $pro_id; ?>"><button type="submit" id="submitUpdateProduct" class="btn btn-default">Submit</button></a>
</form>
可以使你的問題清楚了嗎?或者添加小提琴來了解 – Jagadeesh
nvm修正了它,在別的地方使用過相同的id。 –