I'm using jQuery.ajax()
to submit a form on my website. I get an .xml response and I want to send it to a .php file. I've tried using another jQuery.ajax()
function:
<script type="text/javascript">
$(document).ready(function() {
$('#form').submit(function(e) {
e.preventDefault();
$.ajax({
type: 'POST',
url: 'myURL',
data: $('#form').serialize(),
success: function(xml)
{
$.ajax({
type: 'POST',
url: 'saveData.php',
data: {
xml: $(xml),
},
success: function(data) {
$('#output').html(data);
}
});
}
});
});
})
</script>
but I faced "Illegal invocation"
error. So I added processData: false
to my inner AJAX function. Now I get another error: Undefined index: xml in...
Here is my PHP code:
<?php
$xml = $_POST['xml'];
?>
How to manage this issue?