JQuery XML POST请求 - 未捕获的TypeError

时间:2018-04-13 11:10:37

标签: javascript jquery ajax spring-boot

我得到"未捕获的TypeError:非法调用"在Jquery(POST)中发送XML请求时的消息。

你能说出我做错了吗?关于如何在jquery中发送XML请求POST的任何指针都会有很大的帮助

代码:

$( document ).ready(function() {

    // SUBMIT FORM
    $("#customerForm").submit(function(event) {
        // Prevent the form from submitting via the browser.
        event.preventDefault();
        ajaxPost();
    });


    function ajaxPost(){

        // PREPARE FORM DATA
        var text;
        xmlRequest = "<?xml version=\"1.0\"?>"
            + "<a:InlandDBStructure xmlns:a=\"http://services./inlandpricinglocationretriever/v1\">"
            + "<a:geoids>" + "<a:hubgeoids>"
            + "<a:hubgeoid>12345</a:hubgeoid>"
            + "<a:effectivedt>12-12-2012</a:effectivedt>"
            + "<a:expirydt>12-03-2018</a:expirydt>" + "</a:hubgeoids>"
            + "</a:geoids>" + "</a:InlandDBStructure>";

        if (window.DOMParser)
        {
           parser = new DOMParser();
           xmlDoc = parser.parseFromString(xmlRequest, "text/xml");
        }
        else // Internet Explorer
        {
            xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
            xmlDoc.async = false;
            xmlDoc.loadXML(xmlRequest);
            console.log("here1: ", xmlDoc);
        }

        console.log("xmlDoc: ", xmlDoc);
        console.log("hub: ", $("#hubgeoid").val());
        // DO POST
        $.ajax({
            type : "POST",
            contentType : "text/xml",
            url : "isInlandPricingLocation",
            data : xmlDoc,
            dataType : 'xml',
            success : function(result) {
                if(result != ""){

                }else{

                }
                console.log(result);
            },
            error : function(e) {
                alert("Error!")
                console.log("ERROR: ", e);
            }
        });

    }

})

提前致谢

0 个答案:

没有答案