I have to send an XML via Javascript to PHP and am doing this via jQuery like this:
$.ajax({
url : 'http://myurl',
type : 'POST',
data : { documentXML : escape(xml) },
dataType : 'text',
success : function( data ) {
// Do something
},
error : function() {
alert('Failed to send ajax request!');
}
})
I'm decoding the xml in PHP like this:
if(isset($_REQUEST['documentXML'])) {
$receivedXML = urldecode($_REQUEST['documentXML']);
} else {
die('<?xml version="1.0"?><error>No documentXML given.</error>');
}
However, inside the XML there are other XMLs embedded; this is done by base64 encoding the embedded XMLs. The base64 turns invalid during this process.
Given that changing the XML structure or the encoding is not an option:
- what can I do?
- is the way I'm doing this the right approach?
Thanks.