JSON - Iframe

carsRST
carsRST used Ask the Experts™
on
I have an upload page that returns JSON.  For AJAX purposes, I'm using an Iframe.  I'm trying to capture the data as shown below, but not having luck.  Hoping someone could shed some light.


    var result = JSON.parse($('body', this.contentWindow.document).html());    
 
    if(result.success == 1) { ...}

Only thing that happens is the JSON data is returned and downloaded as a file.

Here's the JSON data returned:
{"success":1,"file_name":"3rd Grade Times-v1.xlsx","file_div":"cube_accepted_date"}
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Multitechnician
Top Expert 2014
Commented:
>For AJAX purposes, I'm using an Iframe.

And why not $.getJSON or $.load ?

http://api.jquery.com/jQuery.getJSON/
http://api.jquery.com/load/

Try this too : http://api.jquery.com/jQuery.parseJSON/

var result = $.parseJSON( $('body', this.contentWindow.document).text() );  

Author

Commented:
Thanks, leakim.

I'm out right now but will try later.

Author

Commented:
Thanks, Leakim, but it's still forcing a download of the JSON data.

Now that I think about it.  I think I may need to capture the JSON data on my IFRAME as oppose to reading the HTML on the IFrame.

Author

Commented:
Thanks, Leakim.  I will use your suggestions.
leakim971Multitechnician
Top Expert 2014

Commented:
You're welcome! Have a nice week-end!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial