ajax networkerror,Ajax NetworkError: A network error occurred
问题
Just yesterday this code was up and running in my LAMP, I'm not sure if I could inflict any major changes. It's a simple ajax script that retrieves data from API.
Today it stopped work, the console just throws "NetworkError: A network error occurred.", even stranger is that when I tried the formatted GET query myself it all worked fine, API responded correctly.
http://localhost/uzduotis2/data/mobile/api/mobile.php?query%5Boperators%5D%5B0%5D=1&query%5Boperators%5D%5B1%5D=2&query%5Boperators%5D%5B2%5D=3&query%5Bmin%5D=180&query%5Bsms%5D=400&query%5Bmb%5D=128&query%5Bperks%5D=7&_=1385898696657
Well, I don't know what else I can do—maybe there was a way to make the error code more specific?... Anyway, here's the code:
function ajaxCall(url, req, req_type, async) {
return jQuery.ajax({
type: req_type,
url: url,
data: req,
contentType: "charset=utf-8",
dataType: 'json',
timeout: 30000,
async: async,
cache: false,
});
}
var ApiUrl = "http://localhost/uzduotis2/data/mobile/api/mobile.php";
$(document).ready(function() {
// .....
var req = {query: {operators: Operators, min: Min, sms: Sms, mb: Mb, perks:Perks}};
var promise = ajaxCall(ApiUrl, req, 'GET', false);
promise.success(function(out) {
console.log(out);
// populate(out);
});
promise.error(function(out){
console.log(out);
});
}
EDIT
I just found out that it works on another browser, must be a cache related issue, maybe somebody knows what could it be?
回答1:
you must return data in asynchrounous way so you must set async to true
var promise = ajaxCall(ApiUrl, req, 'GET', true);
来源:https://stackoverflow.com/questions/20312054/ajax-networkerror-a-network-error-occurred
ajax networkerror,Ajax NetworkError: A network error occurred相关推荐
- ajax进入error函数,报NetworkError: A network error occurred.
现象: ajax调用失败进入error函数,但是java后端也不报错.追踪后发现以下报错: js报错 - NetworkError: A network error occurred. ngi ...
- ipad pro network error occurred
如果 iPad Pro 出现网络错误,您可以尝试以下步骤: 检查您的 Wi-Fi 连接是否正常,确保您的 iPad Pro 正在连接一个可用的 Wi-Fi 网络. 尝试重启 iPad Pro 和您的路 ...
- mybatis:### The error may involve defaultParameterMap### The error occurred while setting parameter
完整报错: Caused by: org.apache.ibatis.exceptions.PersistenceException: ### Error updating database. C ...
- mybatis报错### The error may involve defaultParameterMap ### The error occurred while setting paramete
前两天写的一个springboot+mybatis的小项目在一个修改数据库数据的功能出现了 ###The error may involve defaultParameterMap ###The er ...
- AJAX 笔记 ajax
自己用英文写的笔记,因为输入法切换太麻烦了 \(º □ º l|l)/ AJAX 1. Use Nodejs and Express the basic use of express // 1. im ...
- error An unexpected error occurred “httpsregistry.npmjs.orgd3-geo-proje
error An unexpected error occurred: "https://registry.npmjs.org/d3-geo-proje yarn install 报错 大概 ...
- error An unexpected error occurred: “https://registry.npmjs.org/d3-geo-proje
error An unexpected error occurred: "https://registry.npmjs.org/d3-geo-proje yarn install 报错 大概 ...
- AJAX教程@ajax
文章目录 1.AJAX 1.什么是AJAX 2.AJAX核心对象 - 异步对象(XMLHttpRequest) 1.什么是XMLHttpRequest [简称为 xhr] 2.创建 异步对象 (xhr ...
- ajax - post(),AJAX中的$.post()函数
回答 when(someAjaxDfd).then(function(data){/这里的参数为什么是data,因为在下面的ajax函数中,我把data当成resolve()的参数传过来了 someA ...
- Ajax,jQuery ajax,axios和fetch的区别
Ajax,jQuery ajax,axios和fetch的区别 Ajax: Ajax 即"Asynchronous Javascript And XML"(异步 JavaScrip ...
最新文章
- Virtual host / experienced an error on node rabbit@wohu-rabbit and may be inaccessible
- Linux基础(二)--基础的命令ls和date的详细用法
- 代码优化实战:我又优化了一百个if else!
- 005_Java操作ZooKeeper
- mysql事务实战_MySQL - 实战 (2) - 事务隔离
- 阿里云主机安装Memcached扩展优化WordPress
- 【Android】invalidte和draw的方向
- Wordpress插件检测机制原理
- 基于vue自动化表单实践
- java编程50_java经典50编程题(1-10)
- Shell编程:Bash引号的那点事
- tomcat ---- jndi方式配置连接
- 【VC++类型转换】CString类型到Char[]类型的转换
- Unity编辑器扩展——自定义窗口
- spss分析方法-T检验
- 推荐top10的免费下载破解软件的网站
- 算法提高 字符串跳步
- STM32 控制蜂鸣器播放音乐的原理和实例
- 混频器/变频器的原理及分类
- React回调函数两种常用方式
热门文章
- IEEE论文检测的字体未嵌入问题Times New Roman,Bold, Times New Roman,Italic is not embedded解决方法
- n一加关闭小部件_小部件
- jpa 人大金仓数据库方言_人大金仓+springboot配置
- android xp 支付宝自动提现,支付宝商户如何自动提现?
- 前端工作中的一些解决问题的方法,可以参考一下
- Eat,PrayLove--结婚3周年
- stata基础使用教程(操作版)
- 互联网广告行业术语及缩写
- cnzz统计代码被谷歌浏览器拦截警告
- 机器人大冒险----leetcode