473,322 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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 9695
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

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

Similar topics

16
by: G Matthew J | last post by:
http://htmatters.net/htm/1/2005/07/evaling-JSON.cfm This is more or less in response to Mr Crockford's admonition a few months ago, "fork if you must". Ironically, although in that usenet post...
20
by: Luke Matuszewski | last post by:
Welcome As suggested i looked into JSON project and was amazed but... What about cyclical data structures - anybody was faced it in some project ? Is there any satisactional recomendation... ...
2
by: pgnPoster | last post by:
I am having the dickens of a time figuring this out. I've been googling high and low, but all the examples I find involve the iframe's src containing some HTML albeit minimal. I just want it to...
2
by: Ralph | last post by:
Hi I have problem converting JSON string to an array. The best way to explain this is to show you some code. So : try { var response = that.AjaxReq.responseText.parseJSON(); } catch (myErr)...
5
by: pbd22 | last post by:
Hi. I am trying to poll a long-running process via a hidden IFrame. I am noticing that the online errata gives advice for handling a server response: window.parent.handleServerResponse(); ...
1
by: dan.goyette | last post by:
I'm fairly new to using AJAX. I'm currently developing a data grid application in coldfusion, using AJAX for paging/filter/sorting updates to the grid. So far I've just been returning raw html, and...
5
by: Marc | last post by:
I'm aware that there are significant differences between VBScript objects and JScript objects but that doesn't mean something like the following should give me such troubles? <%@...
3
Kelicula
by: Kelicula | last post by:
Hi all, I am usually a Perl programmer, I have some background in javascript and am attempting to create a Googleish selector div. Please bear with me, excuse the long introduction... Here's...
5
by: najmi | last post by:
hai.. i hava use FullCalendar in my application.i try to reload event into the calendar but it doesn`t work.here is my code <%@ page import="java.util.HashMap;" %> <%@ page...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.