这应该很简单,但我无法在任何地方找到有关如何执行此操作的信息:
$.ajax({
type: 'POST',
url: 'addToBasket.php',
data: 'id='+id,
// ....
error: function(xhr, textStatus, error){
// how to get the id sent to the server?
},
success: function(data, textStatus, xhr){}
});
错误处理函数如何访问请求中发送到服务器的数据?
最佳答案
试试这个可能会有帮助 将“id”作为全局变量发送到服务器并访问它
var id='bla bla'
$.ajax({
type: 'POST',
url: 'addToBasket.php',
data: 'id='+id,
// ....
error: function(xhr, textStatus, error){
// how to get the id sent to the server?
alert(id);
},
success: function(data, textStatus, xhr){}
});
关于JQuery:AJAX 错误:获取发送到服务器的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23041632/