I am using the iframe jquery method to upload a file to my server. My PHP file that processes the uploda returns a JSON string. The returned data is coming back with HTML in the data (which I imagine Firefox is putting in). How can I stop this or just strip out the JSON?
function uploadFile() {
$("#invoice_upload_form").submit();
$('#invoice_upload_frame').on('load',function(e) {
e.preventDefault();
if($(this).contents()[0].location.href.match($(this).parent('form').attr('action')))
{
var html_return = $(this).contents().find('html').html();
//var json_return = JSON.parse(html_return);
alert(html_return);
//alert(json_return);
}
});
}
Comes back as:
<head><link rel="alternate stylesheet" type="text/css" href="resource://gre-resources/plaintext.css" title="Wrap Long Lines"></head><body><pre>{"success":false,"message":"Error importing invoice file"}</pre></body>