ajax请求问题

 $.ajax({
    url:baselocation+"/admin/website/delWebsiteInstitution",
    type:"post",
    data:{"instIds":instIds},
    dataType:"json",
    success:function(result){
        if(result.message){
            alert("删除成功");
            window.location.reload();
        }
    }
});

每次执行到第一行时就直接跳出 不报任何错误

阅读 3.8k
4 个回答

这问题好难答,线索略少。那就根据现在能看到的东西,谈几点问题吧:

  • 根据jquery官网文档,method描述如下:

The HTTP method to use for the request (e.g. "POST", "GET", "PUT")

你是小写post。文档里没说大小写无所谓哦!

  • 根据jquery官网文档,data描述如下:

Data to be sent to the server. It is converted to a query string, if not already a string. It's appended to the url for GET-requests

你确定你是希望你的ajax call是以xxx/admin/website/delWebsiteInstitution?instIds=yy这种方式发送么?

检查下有没有网络请求 然后看下是不是跨域了

是进入success后的第一行么?那就是result逻辑运算的值为false
如果是$.ajax后面不执行,是不是你没有写error 后台返回的是error所以你捕获不到,你写上error接受下,
再有就是在调试器上查看network选项卡
clipboard.png
你发送ajax请求后会有你传递的参数和返回结果,在header和response中

error: function(xhr) {console.log(xhr.responseText);}

调试嘛

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进