如何向json服务器发出CORS ajax post请求

时间:2017-03-12 01:18:46

标签: jquery ajax

我正尝试在下面的代码片段中使用jquery ajax向json服务器发送跨域POST请求:

          var URL = $("#postUrl");
          $.ajax({
            url: URL,
            data: {
                "id": 8,
                "first_name": "Mark",
                "last_name": "Green",
                "phone": "409-324-1345",
                "email": "mark@nexware.com.ng",
                "prefered_exam": "NECO",
                "institution": "greenchamber"
            },
            processData: false,
            type: 'POST',
            async:true,
            crossDomain:true,
            dataType:"json",
            contentType:"application/json; charset=utf-8",
            accepts:{
              "*": "*/*",
              text: "text/plain",
              html: "text/html",
              xml: "application/xml, text/xml",
              json: "application/json, text/javascript"
            },
            success: function ( data ) {
                alert( data );
            }
        });

除了刷新页面之外,它似乎什么都不做。有人请指点我正确的方向帮助

0 个答案:

没有答案