Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery Ajax POST XML structure / Filter Chain

I want to Post an XML structure via AJAX to get a filtered result set. The webservice is able to handle post requests, but something seems to be wrong with my POSTing.

$.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>

Thanks

like image 976
dotchuZ Avatar asked Sep 08 '11 08:09

dotchuZ


1 Answers

$.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);
    } 
}); 

see this SO answer it may help

jQuery ajax post to web service

like image 82
Rafay Avatar answered Nov 10 '22 17:11

Rafay