asp.net-ajax - 如何将来自 Ajax 的数据发布到另一个域?
问题描述
$("body").on("click", "#btnAdd", function () {
//Loop through the Table rows and build a JSON array.
var students = new Array();
debugger;
$("#tblStdnt tbody tr").each(function () {
var row = $(this);
var student = {};
student.Name = row.find("td").eq(1).html();
student.Address = row.find("td").eq(2).html();
student.Phone = row.find("td").eq(3).html();
student.Email = row.find("td").eq(4).html();
student.Adhar = row.find("td").eq(5).html();
student.Qualificaton = row.find("td").eq(6).html();
students.push(student);
});
var testdata = JSON.stringify(students);
//Send the JSON array to Controller using AJAX.
$.ajax({
type: "POST",
url: "http://orionerp.in/imps/post_enquiry.php",
crossDomain: true,
data: JSON.stringify(students),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
alert(r + students);
},
failure: function (msg) {
alert(msg);
},
error: function (xhr, err) {
alert(err);
}
});
});
**错误是**
无法加载http://orionerp.in/imps/post_enquiry.php:对预检请求的响应未通过访问控制检查:请求的资源上不存在“Access-Control-Allow-Origin”标头。因此,不允许访问源“ http://localhost:63315 ”。
解决方案
推荐阅读
- asp.net - 使用 oracle 12c 无法正确获取数据到 asp.net 应用程序
- asp.net - 竹子“合并”旧建筑和新建筑
- html - (SQL ORACLE)如何生成 html 输出,给定 select 语句?
- laravel - Laravel (5.6) 服务提供者
- docker - 将 SSL 证书添加到 NGINX docker 容器
- html - 将字体真棒图标嵌入到外部 css 文件
- angularjs - Wepback导入html模板未加载
- mysql - SQL NOW() 和 SQL 中的 created_at 是什么意思
- android - 如何处理 Kotlin 中的未知字符?
- c++ - 当我不能使用模板时?