Load script with parameters on click
I have a开发者_运维问答ds served via adspeed.com I would like our rich text (testimonial) ads to refresh each time you click a tab link. Is it possible to reload a script when you click a link? currently the script is just placed inside a div as such and executes on page load..
div id="quoteContain">
<!-- AdSpeed.com Serving Code XXX for [Zone] XXX -->
<script type="text/javascript" src="http://g.adspeed.net/ad.php?do=XXX&wd=200&ht=600&target=_top"></script>
<noscript><iframe width="200" height="600" src="http://g.adspeed.net/ad.php?do=XXX&wd=200&ht=600&target=_top" frameborder="0" scrolling="no" >
<a href="http://g.adspeed.net/ad.php?do=XXX&wd=200&ht=600&pair=as" target="_top"><img style="border:0px;" src="http://g.adspeed.net/ad.php?do=img&zid=XXX&wd=200&ht=600&pair=as" alt="i" width="200" height="600"/></a></iframe>
</noscript><!-- AdSpeed.com End -->
<!-- /quoteContain --></div>
I have been trying to remove the script from the div and load it each time with no success
$("ul#flowtabs li a").click(function(){
$("#quoteContain").load("http://link?params");
)};
That's Same Origin Policy giving you hell. Basically, it is preventing you from using XHR to access resources from other domains. I advise you to read linked website.
A possible workaround would be to create a simple proxy to fetch the required script, and inject it into the page upon request.
Everytime you reload a page, you reload all the resources of the page. This is by design. What the browser does is "cache" the results trying to give you a better response time. Otherwise you have to wait for every resource to load. When logo's are frequently 250k and javascript includes another 250k and then CSS files are 50k all of a sudden things start to pile up, and you're looking at a meg or more per page just to show you 50k worth of text. Well that turns into nearly a second or two of loading before you can see the page.
What you need to do is either configure the headers on the returned script to enforce no-caching or you need to make sure that every request includes a random string on the end to make it seem that a new resource is being requested.
Same goes for script-injected tags on an ajax document. The browser will cache what it can.
精彩评论