How to convert jquery collection to xml string for an ajax request
- by Jim
I created a jquery collection that stores xml as follows:
var rh_request = $('')
.attr('user_id', user_id)
.attr('company_id', company_id)
.attr('action', 'x');
I want to post it to my server via an ajax request as follows:
$.ajax({
type: "POST",
url: mywebsiteURL,
processData: false,
dataType: "xml",
data: rh_request.html(),
success: mycallbackfunction
});
My problem is that the "data" parameter of the ajax call needs a string version of the xml and it seems neither Jquery's .html() or .text() function yields this. I have older code that used straight javascript to form the outgoing xml and calling the DOM .xml() function yielded a string that worked. How is this done with a jquery collection???