小编Xri*_*ter的帖子

jQuery ajax请求:如何在成功函数中访问发送的数据?

所以我试图实现以下目标,但我无法弄清楚如何使这项工作.

$.ajax({
  url: "whatever.php",
  method: "POST",
  data: { myVar: "hello" },
  success: function(response) {
    console.log('received this response: '+response);
    console.log('the value of myVar was: '+data.myVar); // <<<< data.myVar is not accessible from here
    console.log('the value of myVar was: '+myVar); // <<<< myVar is not accessible from here
  }
});
Run Code Online (Sandbox Code Playgroud)

是否有访问的价值方式myVar.success()功能?我可以以某种方式获取data在此.success()函数中在此ajax请求中发送的原始对象吗?

希望你的解决方案.谢谢!

javascript ajax jquery

7
推荐指数
3
解决办法
9506
查看次数

标签 统计

ajax ×1

javascript ×1

jquery ×1