加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读