0

Is it possible to do something like this?

var xmlString = 
            '<?xml version=1.0 encoding=UTF-8 standalone=yes ?>'+
            '<Requests>'+
              '<Request type=GetMeasures>'+
                '<Filter>'+
                  '<BBox top=52 bottom=51.3 left=7.3 right=7.7 />'+
                '</Filter>'+
              '</Request>'+
            '</Requests>';

$.ajax({ url: URL, type: "POST", ontentType: "text/xml", processData: false, data: xmlString_HasMeasures, success: function(response){ alert(response); } });

So far doenst work for me. Can JQuery just pass key-value pairs? Thanks!

5
  • have you try using xml only on the contentype? btw you have an error on contentType it's missing a c Commented Nov 23, 2011 at 23:44
  • 1
    if you copy/pasted that from ure actuall code, then you should fix ontentType to contentType Commented Nov 23, 2011 at 23:45
  • also, is xmlString_HasMeasures supposed to be what you've declared to be xmlString? Commented Nov 23, 2011 at 23:45
  • possible duplicate of how to pass xml as parameter using POST method and using jquery ajax Commented Nov 23, 2011 at 23:51
  • ok without typo it doesnt work either :-/ Yes xmlString_HasMeasures is my XML string. something wrong with that? Commented Nov 24, 2011 at 8:36

3 Answers 3

1

You might as well use $.post(). And yes, because this will be x-www-form-urlencoded, you need a key to go with that XML value.

$.post(URL, {data: xmlString}, function (response) {
    alert(response);
});
Sign up to request clarification or add additional context in comments.

1 Comment

Strange thing, that it isnt possible to just post a http-body.
0
$.ajax({ 
    type: "POST", 
    url: "", 
    data: { inputxml: escape('<test></test>')}, 
    success: function(msg) { }, 
});

Comments

0

To post xml/html to the server, you have to escape it.

$.ajax({ url: URL, 
         type: "POST",
         data: {inputxml: escape(xmlString_HasMeasures)}, 
         success: function(response){ alert(response); } 
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.