Get remote <iframe> content...
Moderator: Neosoft Support
-
- Posts: 1596
- Joined: Mon Apr 04, 2005 4:13 pm
- Location: Buenos Aires, Argentina
- Contact:
Get remote <iframe> content...
Hi all,
this PHP shows the ip of your machine:
http://soporte.byethost7.com/ip.php
I can see the <iframe> within the neoapp, and the content.
I need catch the content of this iframe and put it into an alert(...), but nothing works...
Any ideas ?
Thanks in advance,
David de Argentina
this PHP shows the ip of your machine:
http://soporte.byethost7.com/ip.php
I can see the <iframe> within the neoapp, and the content.
I need catch the content of this iframe and put it into an alert(...), but nothing works...
Any ideas ?
Thanks in advance,
David de Argentina
Re: Get remote <iframe> content...
David de Argentina:
Note that ...
1) you don't need the command ...
$('#Container2').html("wxyz");
... I just use it to observe actual changes during testing.
2) the command ...
gkTemp = "temp"
... was placed as a workaround (for running as a WebApp) in previous beta of NeoAppBuilder ... don't know if it has been fixed in latest beta.
With this code, I got the expected returned data.
You don't need to use the < iframe > element ... here is some code I attached to a Push Button's click event ...Any ideas ?
Code: Select all
BeginJS
$('#Container2').html("wxyz");
alert("before .get");
$.get("http://soporte.byethost7.com/ip.php", function(data,status){
$('#Container2').html(data);
alert("Data: " + data);
},'text');
gkTemp = "temp";
EndJS
1) you don't need the command ...
$('#Container2').html("wxyz");
... I just use it to observe actual changes during testing.
2) the command ...
gkTemp = "temp"
... was placed as a workaround (for running as a WebApp) in previous beta of NeoAppBuilder ... don't know if it has been fixed in latest beta.
With this code, I got the expected returned data.
-
- NeoSoft Team
- Posts: 5628
- Joined: Thu Mar 31, 2005 10:48 pm
- Location: Oregon, USA
- Contact:
Re: Get remote <iframe> content...
You shouldn't need gkTemp = "temp" anymore.
The jQuery get command works in Chrome but for some reason it doesn't do anything in IE. No response, no error messages, nothing.
The jQuery get command works in Chrome but for some reason it doesn't do anything in IE. No response, no error messages, nothing.
NeoSoft Support
-
- Posts: 1596
- Joined: Mon Apr 04, 2005 4:13 pm
- Location: Buenos Aires, Argentina
- Contact:
Re: Get remote <iframe> content...
WOW !!!
Beautiful ! Beautiful ! Beautiful ! Beautiful ! Beautiful ! Beautiful ! Beautiful ! Beautiful !
Thanks !
David de Argentina
Beautiful ! Beautiful ! Beautiful ! Beautiful ! Beautiful ! Beautiful ! Beautiful ! Beautiful !
Thanks !
David de Argentina
Re: Get remote <iframe> content...
Dave:
Thanks for the update ... I will remove all such work arounds from my Test AppYou shouldn't need gkTemp = "temp" anymore.
Good to know ... BTW, works in Firefox too.The jQuery get command works in Chrome but for some reason it doesn't do anything in IE. No response, no error messages, nothing.
-
- Posts: 1596
- Joined: Mon Apr 04, 2005 4:13 pm
- Location: Buenos Aires, Argentina
- Contact:
Re: Get remote <iframe> content...
if you need wait for complete file download, in order to process the returned data, you must turn off the asynchronous (default) mode of $.get
The trick is:
This is not ellegant, and the debug console should tell you a warning message, but is very effective.
My 0.01
David de Argentina
The trick is:
Code: Select all
jQuery.ajaxSetup({async:false});
$.get(...);
jQuery.ajaxSetup({async:true});
My 0.01
David de Argentina
Re: Get remote <iframe> content...
David de Argentina:
... aren't the commands within the function (data,status){...} i.e. ...
... serviced AFTER the download is complete ?
Not sure what you are talking about ... if you use ...if you need wait for complete file download, in order to process the returned data, you must turn off the asynchronous (default) mode of $.get
Code: Select all
$.get("http://soporte.byethost7.com/ip.php", function(data,status){
$('#Container2').html(data);
alert("Data: " + data);
},'text');
Code: Select all
$('#Container2').html(data);
alert("Data: " + data);
-
- Posts: 1596
- Joined: Mon Apr 04, 2005 4:13 pm
- Location: Buenos Aires, Argentina
- Contact:
Re: Get remote <iframe> content...
Hi Gaev,
Figure you need get some values from your received data with something like getElementById... or similar.
If you put this stament ...getElementById inmediatly after the $.get() function, the most probabily is you get an error message, because data could be dowloading at this time.
As $.get() is an asynchronous function, inmediatly returns the control to the next action, and, at this moment, you does not have the data.
Pretty confuse ?
Figure you need get some values from your received data with something like getElementById... or similar.
If you put this stament ...getElementById inmediatly after the $.get() function, the most probabily is you get an error message, because data could be dowloading at this time.
As $.get() is an asynchronous function, inmediatly returns the control to the next action, and, at this moment, you does not have the data.
Pretty confuse ?
Re: Get remote <iframe> content...
David de Argentina:
1) regarding the use of async:false ...
On this page http://api.jquery.com/jquery.ajax/ ... it says that ...
If you find this type of coding difficult to read (especially when you start nesting Asynchronous commands), you can place "the code to be serviced when the requested data is received" in a separate function like this ...
1) regarding the use of async:false ...
On this page http://api.jquery.com/jquery.ajax/ ... it says that ...
... and on this page http://stackoverflow.com/questions/1478 ... query-ajax ...it says that ...As of jQuery 1.8, the use of async: false with jqXHR ($.Deferred) is deprecated; you must use the success/error/complete callback options instead of the corresponding methods of the jqXHR object such as jqXHR.done() or the deprecated jqXHR.success().
... and on this page http://stackoverflow.com/questions/8929 ... move-event ... it says that ...Remember that this also means that browser will not capture/trigger any events happening while ajax is being executed. I found this out the hard way, trying to figure out why Firefox was not triggering a click event. It turned out to be because of a "forced" blur event with a following sync call blocking it.
2) I didn't invent the command syntax for this AJAX stuff (and jQuery's $.get() is just a layer on top of AJAX) ... but they chose this difficult (for some) to understand syntax for specifying the "callback function" i.e. "what to do when the requested data is made available" ... in your example, if getElementById is to be performed AFTER the data is received, you would do something like this ...This code stops mousemove event
async:false halts the browser, all JavaScript, until it's done
Code: Select all
$.get("http://soporte.byethost7.com/ip.php", function(data,status){
//your getElementById stuff goes here
},'text');
Code: Select all
function doThisUponReceiptOfData(data,status) {
//your getElementById stuff goes here
}
$.get("http://soporte.byethost7.com/ip.php",doThisUponReceiptOfData ,'text');