ajax(jsonp)发送ajax跨域请求

时间:2022-08-28 15:27:06

1、ajax发送ajax跨域请求设置jsonp参数

$.ajax({
url:baseUrl + "/voiceUpload/saveVoiceMessage",
method:"get",
data:{
voiceNumber : voiceNumber,
voiceName : encodeURI(voiceName),
voiceSize : voiceSize,
voiceType : voiceType,
status:status
},
dataType:"jsonp",
jsonp: 'jsoncallback',
success:function (response) {
//弹出提示框
$scope.showKnowFlag = true;
$scope.knowMessage = response.message;
$scope.modalFlag = true;
//调用转写后将数据进行清除
voiceNumber = "";
voiceName = "";
voiceSize = "";
voiceType = "";
voiceCount = 0;
selectCount = 0;
},
error:function () {
//调用转写后将数据进行清除
voiceNumber = "";
voiceName = "";
voiceSize = "";
voiceType = "";
voiceCount = 0;
selectCount = 0;
}
});