I'm building a PHP page that will load some off site content into a DIV. There are other static elements on the page also. The problem I'm having is that the page takes too long to load because PHP loads the off site content before displaying the page.
I am considering loading the off site content in the DIV via AJAX. I'm assuming the rest of the page would load regardless of how long it takes the AJAX DIV to load.
The content will not need to update or change while the original page is loaded. It just needs to load the content once.
I have been searching for a while and have found a lot of different techniques for doing this. Such as jQuery.
Do you have any suggestions on how to do this?
Any links to tutorials would be great.
Thanks
I guess this can help you:
$('#result').load('ajax/test.html');
Reference: jquery
If you control the second (off-site) domain, you can get around the same-origin policy issues by loading a script on the secondary domain. That script should kick off the various AJAXish content updates you want.
on example1.com:
<div id="stuff-from-example2"></div>
<script src="http://www.example2.com/js/stuff.js"></script>
in stuff.js:
$('#stuff-from-exampl2").load('http://www.example2.com/fragment.html');
You can get around the same-origin policy by loading the data using JSONP.
Here are the JQuery docs
Related
I have an audio streaming website and thus we need to keep the audio playing while the user navigate from one page to another page in the website. So to achieve the above, we need to load the content using Ajax. We are now trying to use Adsense ads in our website and observed that the ads doesn't get loaded when the content of an other page is being loaded using Ajax. So can you help how to use it. I tried using an separate html page where ads are placed and include it using iframe, this works but I am unsure if this is allowed by Adsense. Can you please confirm me if this approach using iframe is allowed or if there is any alternative workaround to load the ads.
I also tried to contact Adsense but I didn't find any contact details.
How do you load ads currently? But generally the process will be the following:
Using ajax add <ins class="adsbygoogle" ...> elements where you want to see ad.
Once DOM is updated run adsbygoogle.push({}); from JS to trigger ad load.
I am trying to write an application in style of 4chan thread saver. I know that I can make a screenshot using html2canvas and even managed to do it. But how to load a html page without load it in browser? I care about keep the style of the page
This is not a jQuery issue. However, you should be able to do a XMLHttpRequest defined here and supply the url, to get the web page html back.
My webpage is loading all it's content through AJAX. In Chrome, when I go to print, it only displays the header and footer which are set and not served using AJAX (it's simply blank where the content is clearly visible in the browser). Is there a known solution to this, or documentation on AJAX and it's interaction with printing/saving from the browser?
You might want to look at jquery printArea plugin
https://plugins.jquery.com/PrintArea/
We had a similar issue and the workaround we came up with was to create a hidden dom element (either a div or iframe) with all the content to print and used printArea to handle the printing
i want to load a specific part of website in iframe, unfortunately iframe is not loading , i have tried object, iframe, framset and jquery too load but i am failed.
I need your help to sort it out and show a specific part from this website
http://www.weddingwire.com/weddings/2816607/wedding_new_website/preview
i need this part of website (http://prntscr.com/30051k)
Please help me .
Thanks
You won't be able to embed this website using iframe since it have X-Frame-Options header.
You can try displaying it with curl.
I have an iframe that loads a form from another site into my site (I control both domains but they are different).
The iframe is loaded into a fancybox on my site and I would like it to popup an AJAX loading graphic when the form in the iframe is processing.
I know I can't directly add event listeners to the iframe form other site but is there any way that my site can know what is going on in the iframe?
No there's no way of knowing what another iframe is doing.
Have the domain (the one inside the iframe) load the AJAX loading graphic before the content shows up, all on the server side... you don't need the client for this.
I agree with Luca, but then your form will have to be loaded before the AJAX loading graphic can be displayed. If it is a very large form, this might take a while and will perhaps defeat the purpose of the loading graphic.
Have you considered loading the contents of the form via javascript instead, bypassing the iframe altogether? Just GET the contents of the form and load it into a div? (Granted, if the form you're loading is complex, that might cause more problems)
It is absolutely forbidden by browsers to know what is going on in the iframe.