weixin_33735676 2018-12-09 03:05 采纳率: 0%
浏览 25

Ajax成功未运行

So im having a weird issue. I made a small application on my machine that works fine but when I upload to a school server it stops working. What I am doing is accessing json data with ajax. I have tested and I am getting the correct json responses, I am connecting to the database just fine and the ajax is running every two seconds as it should. But the code in the success section of the ajax never runs. The database on the server is identical to the one on my machine, the connection has been troubleshooted and works great but still the ajax success code doesn't run. Thanks in advance!

setInterval(function () {
            $.ajax({
                type: 'GET',
                url: 'JSONFile.php',
                dataType: 'json',
                success: function (retrieved) {
                    $.each(retrieved, function (index, i) {
                         alert('This line of code is the problem. This alert does not run but should');
                    });
                }
            });
        }, 2000);
  • 写回答

2条回答 默认 最新

  • hurriedly% 2018-12-09 03:54
    关注

    jQuery 3 is coded using done, fail and always

    // Assign handlers immediately after making the request,
    // and remember the jqXHR object for this request
    var jqxhr = $.ajax( "example.php" )
      .done(function() {
        alert( "success" );
      })
      .fail(function() {
        alert( "error" );
      })
      .always(function() {
        alert( "complete" );
      });
    

    https://api.jquery.com/jQuery.ajax/

    Deprecation Notice: The jqXHR.success(), jqXHR.error(), and jqXHR.complete() callbacks are removed as of jQuery 3.0. You can use jqXHR.done(), jqXHR.fail(), and jqXHR.always() instead.

    评论

报告相同问题?

悬赏问题

  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)