【发布时间】:2018-03-30 04:47:44
【问题描述】:
我想向远程 API 发送 AJAX 请求。
function Gettest(CourseID) {
var param = { "CourseID": CourseID};
param = JSON.stringify(param);
$.ajax({
type: "Post",
url: apiurl + "Course/DelCoursetargetedaudience",
contentType: "application/json; charset=utf-8",
data: param,
dataType: "json",
success: function (data) {
},
error: function (response) {
}
});
};
但我需要在发送请求之前更改源名称。
请参考下图。
【问题讨论】:
-
为什么要改?
-
感谢您的回复。我有我的生产 API。那里不允许本地主机请求。
-
你应该看看 CORS 让服务器允许跨域请求
-
是的,我也这样做了,我只允许一个来源.. 但不改变我需要发送请求
-
那很好......有没有办法在向服务器请求时更改来源
标签: javascript jquery asp.net asp.net-web-api