|
下面这句,在chrome浏览器上直接执行,是有返回值的
https://aip.baidubce.com/rpc/2.0 ... 0332.282335-8574074
返回:
{"error_msg":"Access token expired","error_code":111}
而在wex5里,在button click事件里,总是返回JUSTEP230109.
$.ajax({
"type" : "post",
"async" : false,
"dataType" : "json",
"url" : "https://aip.baidubce.com/rpc/2.0/nlp/v1/wordseg",
"data" : {
"access_token" : "24.f9ba9c5241b67688bb4adbed8bc91dec.2592000.1485570332.282335-8574074",
},
"complete" : function(xhr) {
if (xhr.readyState == 4 && xhr.status == 200) {
//alert("成功!"); //成功就不提示了
} else {
alert("发送失败!");
}
},
"error": function(){ //失败
alert('Error loading document');
},
"success": function(msg){ //成功
alert( "返回数据: " + msg );
}
});
奇怪的是,我写的另外一个例子,ajax访问图灵机器人api的就没有这个现象:
$.ajax({
"type" : "post",
"async" : false,
"dataType" : "json",
"url" : "http://www.tuling123.com/openapi/api",
"data" : {
"key" : "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
"info" : "",
// "loc" : "",
"userid" : "123456",
},
"complete" : function(xhr) {
if (xhr.readyState == 4 && xhr.status == 200) {
//alert("成功!"); //成功就不提示了
} else {
alert("发送失败!");
}
},
"error": function(){ //失败
alert('Error loading document');
},
"success": function(msg){ //成功
// alert( "返回数据: " + msg );
}
}); |
|