javascript - Ajax调用总是失败

标签 javascript html ajax jquery

<script type="text/javascript">
function dialogsf() {
     $("#loadingsf").dialog({
         hide: 'slide',
         show: 'slide',
         autoOpen: true
     });
     $("#loadingsf").dialog('open').html("<p>Please Wait while contacts are imported...</p>");
     //alert("dfsd");
 }
 var fd = 1;
 $(document).ready(function () {
     dialogsf();
     $.ajax({
         url: "get_contacts.php",
         type: "GET",
         data: {
             sid: 'a'
         },
         processData: false,
         contentType: false,
         success: function (response) {
             // alert("Import done successfully with "+contacts.length+ " contacts");
             alert("Import done successfully");
             $('#loadingsf').html("<p>Result Complete...</p>");
         }
     }).fail(function (xhr, status, error) {
         alert('error:' + status + ':' + error + ':' + xhr.responseText)

     }).done(function (respond) {
         location.href = respond;

     });

 });
</script>
    <body >
    <div id="loadingsf" title="SF Contact Import"> 
    <p>Please wait ...</p>
</div>

这是我正在处理的片段。 当我运行特定页面时,我收到此 "error:error::" 不知道为什么ajax调用总是失败,控制台也是空的

最佳答案

删除 contentType:false 或将正确的 contentType 设置为 contentType: "application/json"

关于javascript - Ajax调用总是失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18611871/

相关文章:

php - jquery ajax 多个请求

javascript - 使用ajax将复选框多个数组传递给php

javascript - 如何在json2html库中使用li标签

javascript - knockout .js : ObservableArray with ObservableArrays inside?

javascript - Node postgres 并获取具有重复名称的连接字段

android - 如何在 HTML 的帮助下在 Android 和 iPhone 中启动添加新的联系人屏幕,而无需任何服务器端代码?

html - 将页脚保持在响应式网站的底部

javascript - 在 Ajax 调用中调用辅助方法

javascript - 在 Firebase 中使用 Push() 不起作用

html - CSS、HTML 在所有尺寸的屏幕上保持外观相同