473,390 Members | 1,349 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,390 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 9720
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.