如何将Ajax中的数据发布到另一个域上?

时间:2018-07-28 15:18:31

标签: asp.net-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”。

0 个答案:

没有答案