[英]I want to pass multiple parameters in post method using ajax.
This is the code.这是代码。 Here I want to pass item id , stock quantity and price using ajax in post method.在这里,我想在 post 方法中使用 ajax 传递项目 id 、库存数量和价格。 Its really great if someone can help me .如果有人可以帮助我,那就太好了。 Thankss inadvance提前谢谢
function update_item(item_id, sellingPrice,stockQty){
// alert (sellingPrice);
var item = item_id;
var sellingPrice = sellingPrice;
var stockQty = stockQty;
//var temp = "#"+item_id;
//var temp1 = "'"+temp+"'";
alert ("hii");
$.ajax({
url : 'UpdateItem2.php',
method : 'POST',
data : {"item=" : item + "sellingPrice=" : sellingPrice + "stockQty=" : stockQty},
alert (item);
success : function($result){
alert("Stock upated successfully");
}
});
}
</script>
You have an alert() inside an object declaration, that wont work.您在对象声明中有一个 alert(),它不起作用。 Also you need to comer separate each element of your data object like this:您还需要像这样将数据对象的每个元素分开:
data: {"foo": "bar", "bar": "foo"}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.