我想通过
AJAX发布一个
XML结构,以获得一个过滤的结果集. webservice可以处理post请求,但是我的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>
谢谢
解决方法
$.ajax({ url: ajaxurl,data: "<test></test>",thrownError){ console.log(xhr.status); console.log(thrownError); } });
看到这个SO答案可能有帮助