atubo
atubo
  • 发布:2015-08-06 14:29
  • 更新:2016-04-12 17:00
  • 阅读:2102

ajax请求出错

分类:MUI

代码如下:
var url = 'http://120.24.176.140:8080/bull/server/resources';
var dataRequest1 = {
requestHeader:{
resource: 'system',
actionType: 'getSmsCode'
},
requestBody:{
type: '001',
mobile: '13632753369'
}
};

$.ajax(url,{
data:dataRequest1,
dataType:'json',//服务器返回json格式数据
type:'post',//HTTP请求类型
timeout:10000,//超时时间设置为10秒;
success:function(data){
console.log("aaaaaaaaa");
},
error:function(xhr,type,errorThrown){
console.log(type+" xhr:"+xhr.responseText);
}
});

打印的log如下:
error xhr:<html><head><title>Apache Tomcat/7.0.56 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 415 - Unsupported Media Type</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>Unsupported Media Type</u></p><p><b>description</b> <u>The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.56</h3></body></html>

请问是什么问题啊?

2015-08-06 14:29 负责人:无 分享
已邀请:
mario6

mario6

我也是这个问题。。很郁闷呢

DCloud_UNI_FXY

DCloud_UNI_FXY

排查服务器接收的类型。然后自己设置ajax的Content-Type

该问题目前已经被锁定, 无法添加新回复