簡體   English   中英

JQuery Ajax POST XML結構/過濾器鏈

[英]JQuery Ajax POST XML structure / Filter Chain

我想通過AJAX發布XML結構來獲取過濾結果集。 web服務能夠處理發布請求,但我的POST發生似乎有些問題。

$.ajax({
    url: ajaxurl,
    data: {
        inputxml: escape('<test></test>') <- how to post xml structure correctly?
    }, 
    type: 'POST',
    contentType: "text/xml",
    dataType: "text",
    success : parse,
    error : function (xhr, ajaxOptions, thrownError){  
        alert(xhr.status);          
        alert(thrownError);
    } 
}); 

XML:

<?xml version="1.0" encoding="UTF-8"?>
<f:filterChain
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:f="urn:foo">
    <f:filter attributeId="number">
        <f:rangeCondition conditionSign="INCLUSION" operator="BETWEEN">
            <f:low>5</f:low>
            <f:high>15</f:high>
        </f:rangeCondition>
    </f:filter>
</f:filterChain>

謝謝

$.ajax({
    url: ajaxurl,
    data: "<test></test>", 
    type: 'POST',
    contentType: "text/xml",
    dataType: "text",
    success : parse,
    error : function (xhr, ajaxOptions, thrownError){  
        console.log(xhr.status);          
        console.log(thrownError);
    } 
}); 

看到這個答案可能有所幫助

jQuery ajax發布到Web服務

也許最好在對象中設置值,並通過將ajax方法的dataType設置為'xml'將該對象作為xml發送到服務器。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM