i submit my form into an iframe via jquery. i got the result from the php file in JSON code. How can i use this string in my javascript?
form
<form target="iframe" method="post" action="upload.php" enctype="multipart/form-data">
...
</form>
response fromupload.php printed into the iframe
{"datafile":{"name":"","type":"","tmp_name":"","error":4,"size":0}}
whats the best way to register a callback if the response from the php arrived, and then access to the datafiles 's error property?
Try to attach a load handler to the iframe.
$('#iframe').on('load', handler)
inside the handler you can get the iframe body and extract the json and parse it for use. You can do something like this in the handlerNote Same Origin Policy applies so this will not work if the post is made to another origin.