Answer the question
In order to leave comments, you need to log in
jQuery XML generation and sending to server via Ajax?
I would like to send ajax to the xml server, which contains the parameters received from the form.
I do something like this:
function forming_ajax_request(){<br>
var arg_1 = $('#form_1_arg_1').val();<br>
var arg_2 = $('#form_1_arg_2').val();<br>
<br>
var my_xml = $('<xml />');<br>
var arg = $('<arg />', {'value': arg_1});<br>
$(my_xml).append($(arg));<br>
var arg = $('<arg />', {'value': arg_2});<br>
$(my_xml).append($(arg));<br>
<br>
jQuery.ajax({<br>
type: "POST",<br>
url: '#{ajax_url}',<br>
data: {my_xml: my_xml},<br>
dataType: "html",<br>
success: function(data, status, xhr){ alert('Success') },<br>
beforeSend: function(xhr){ alert('Before') },<br>
complete: function(xhr, status){ alert('Complite') },<br>
error: function(xhr, status, error){ alert('Error') }<br>
});//jQuery.ajax<br>
}<br>
Answer the question
In order to leave comments, you need to log in
Ummm, well, if you do xml like this $(my_xml).append($(arg));
,
then what prevents you from calling the jquery function .html();
for your object?
data: {my_xml: my_xml}
There is a chance, after converting xml to text form, to get an unexpected key =)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question