微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ajax请求时,在url没错的情况下返回error问题

//在用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"这句话删掉

原文地址:https://www.jb51.cc/ajax/162207.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐