retrieve json file from server

南楼画角 提交于 2019-12-06 13:36:32

First of all, try using $.getJSON() instead of plain $.ajax(). it will solve many problems right off the bat.

http://api.jquery.com/jQuery.getJSON/

Secondly, make sure your json file is formatted perfectly, without any loose characters and strange whitespaces.

Also try to chain an error handler to your ajax call. available in the getJSON documentation above.

var jqxhr = $.getJSON("example.json").error(function() { alert("error"); });
// this is according to documentation, i cannot currently test this to work, sorry about that.
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!