【问题标题】:Ajax doesn't work in firefoxAjax 在 Firefox 中不起作用
【发布时间】:2018-02-09 10:59:09
【问题描述】:

此代码在 Firefox 中不起作用,在 chrome 中它起作用,我正在得到结果

console.log('send');
$.ajax({
  url: my_object.ajax_url,
  type: 'POST',
  data: {
    action: 'sendPhone',
    phone: '23342342',
    city: 'sddsfsf',
  },
  beforeSend: function(){
    console.log('beforeSend');
  },
  success: function(msg){
    console.log('result = '+msg);
    return;
  },
});//end $.ajax

chrome 输出 这是Firefox中的输出 谁知道为什么 $.Ajax 不起作用?

在我们的森林里发生了一些奇怪的事情...... :(

【问题讨论】:

  • 更改 return 以返回 true?需要更多代码
  • 我认为 return 是不必要的,你在成功块结束后给了逗号,这似乎是不必要的
  • 在控制台的网络选项卡中检查从请求中实际返回的内容。同时删除return 语句。它在您的异步 success 处理程序中完全是多余的。

标签: javascript jquery ajax google-chrome firefox


【解决方案1】:

试试这个: `

console.log('send');
$.ajax({
  url: my_object.ajax_url,
  type: 'POST',
  data: {
    action: 'sendPhone',
    phone: '23342342',
    city: 'sddsfsf',
  },
  beforeSend: function(){
    console.log('beforeSend');
  }
  })
  .success(function(msg){
    console.log('result = ' + msg);
  });

`

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-02
    • 2012-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多