ajax请求时,在url没错的情况下返回error问题
发布时间:2020-12-16 01:39:32 所属栏目:百科 来源:网络整理
导读://在用ajax进行请求时,没有任何差错,但是总是返回error,不走succees,ajax代码如下jQuery(document).ready(function($){$.ajax({url:"customerServlet?method=addname="+encodeURI(encodeURI(name))+"source="+encodeURI(encodeURI(source))+"status="+enc
//在用ajax进行请求时,没有任何差错,但是总是返回error,不走succees,ajax代码如下 jQuery(document).ready(function($){ $.ajax({ url:"customerServlet?method=add&name="+encodeURI(encodeURI(name))+"&source="+encodeURI(encodeURI(source))+"&status="+encodeURI(encodeURI(status))+"&userID="+encodeURI(encodeURI(userID))+"&contactTime="+encodeURI(encodeURI(contactTime))+"&timeOfContact="+encodeURI(encodeURI(timeOfContact))+"&money="+encodeURI(encodeURI(money))+"&address="+encodeURI(encodeURI(address))+"&phone="+encodeURI(encodeURI(phone))+"&remarks="+encodeURI(encodeURI(remarks))+"&file="+encodeURI(encodeURI(file)),type:"post",dataType:"json",success:function(msg){ //alert(msg); console.log(msg+"1111"); },error:function(msg){ alert(msg); } }); }); 这是因为dataType:"json",返回的必须是一个json,如果不是json,那么就会走error,如果返回的不是一个json,那么就需要把dataType:"json"这句话删掉 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- PostgreSQL 8.4, SQL Server 2008, MySQL 5.1比较
- 转:sqlite操作
- 基于XML的API自动化测试工具设计与实现
- React-Native中Array的key警告
- extjs JsonStore加载数据,Combobox只显示最后一项值问题
- 戴尔聚合网络适配器(Converged Network Adapter, CNA) 在RH
- WPF无法让命令和依赖属性一起工作,或者我只是错误地使用它们
- (十)swift UICollectionViewController常用操作(swift 九
- vue的props实现子组件随父组件一起变化
- 您最喜欢.NET和Oracle的ORM框架是什么?