469,315 Members | 1,605 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,315 developers. It's quick & easy.

IFrame - getting the JSON response

Hi all,

I am currently working with Iframe which holds the JSON response from the server once when the picture gets uploaded successfully. Now I need to parse the JSON response and retrieve the id of the image uploaded.

My Iframe is here

Expand|Select|Wrap|Line Numbers
  1. <iframe id="PUIFrame"
  2.   name="PUIFrame"
  3.   style="width:300px; height:200px; border: 5px;" src="blank.html">
  4.   </iframe>
The response is of the form

Expand|Select|Wrap|Line Numbers
  1. {picture: {content_type: "image/jpg", name: "SliderPuzzle", id: 58}, caption: "", id: 58}
I am able to view the response from the server. I need some ways to get the image id.

I got stuck up with this.

Any help would be greatly appreciated.

With thanks,
Amutha
Jul 26 '07 #1
4 9223
gits
5,390 Expert Mod 4TB
hi ...

assuming that you know how to use your responseText, try the following:

Expand|Select|Wrap|Line Numbers
  1. // eval the json-string to an native js-object
  2. // what is the origin. purpose of json at all
  3. var response = eval(request.responseText);
  4.  
  5. // now you may use the typical reference methods for
  6. // objects or arrays like:
  7. var img_id = response.id;
  8.  
kind regards
Jul 26 '07 #2
pbmods
5,821 Expert 4TB
Heya, Amutha. Welcome to TSDN!

I award 12 points for creative use of [i] tags. Unfortunately, I have to deduct 12 points for using [i] tags when you should have used [code] tags.

Better luck next time.

Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.
Jul 26 '07 #3
Hi all,

Thanks for your replies. I would post the code in [code]
tags.

I am not using AJAX for posting the request. In my case my form's target
points to an IFrame and so the response is received in the IFrame.
I tried invoking a function to get the response and then parse it for
the Image id.

Is there any way to proceed with this?

With thanks,
Amutha
Jul 27 '07 #4
gits
5,390 Expert Mod 4TB
hi ...

i showed you already. retrieve the string you showed in your original post from your iframe and use use the things i showed ... that will do the job. doesn't matter to use ajax or not ... you always can eval the json-string when you have it ... in your case you would simulate it ... when you hide your iframe ;) ... typically we use that as an fallback option when no XMLHttpRequest-Object is available ... please, ask more questions in case i didn't make myself very clear ...

kind regards
Jul 27 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

16 posts views Thread by G Matthew J | last post: by
20 posts views Thread by Luke Matuszewski | last post: by
2 posts views Thread by pgnPoster | last post: by
2 posts views Thread by Ralph | last post: by
5 posts views Thread by pbd22 | last post: by
1 post views Thread by dan.goyette | last post: by
Kelicula
3 posts views Thread by Kelicula | last post: by
5 posts views Thread by najmi | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.