Search Results

Search found 57 results on 3 pages for 'getscript'.

Page 1/3 | 1 2 3  | Next Page >

  • Using resize to getScript if above x pixels (jQuery)

    - by user1065573
    So I have an issue with this script. It basically is loading the script on any resize event. I have it working if lets say... - User has window size above 768 (getScipt() and content by .load() in that script) - Script will load (and content) - User for some reason window size goes below 768 (css hides #div) - User re-sizes again above 768, And does not load the script again! (css displays the div) Great. Works right. Now.. (for some cray reason) - User has window size below 768 (Does NOT getScript() or nothing) - User re-sizes above 768 and stops at any px (getScript and content) - User re-sizes again anything above 768 (It getScript AGAIN) I need it to only get script once. Ive used some code from here jQuery: How to detect window width on the fly? (edit - i found this, which he has the same issue of loading a script once.) Problem with function within $(window).resize - using jQuery And others i lost the links to :/ When i first found this problem I was using something like this, then i added the allcheckWidth() to solve problem. But it does not. var $window = $(window); function checkWidth() { var windowsize = $window.width(); ////// LETS GET SOME THINGS IF IS DESKTOP var $desktop_load = 0; if (windowsize >= 768) { if (!$desktop_load) { // GET DESKTOP SCRIPT TO KEEP THINGS QUICK $.getScript("js/desktop.js", function() { $desktop_load = 1; }); } else { } } ////// LETS GET SOME THINGS IF IS MOBILE if (windowsize < 768) { } } checkWidth(); function allcheckWidth () { var windowsize = $window.width(); //// IF WINDOW SIZE LOADS < 768 THEN CHANGES >= 768 LOAD ONCE var $desktop_load = 0; if (!$desktop_load) { if (windowsize < 768) { if ( $(window).width() >= 768) { $.getScript("js/desktop.js", function() { $desktop_load = 1; }); } } } } $(window).resize(allcheckWidth); Now im using something like this which makes more sense? $(function() { $(window).resize(function() { var $desktop_load = 0; //Dekstop if (window.innerWidth >= 768) { if (!$desktop_load) { // GET DESKTOP SCRIPT TO KEEP THINGS QUICK $.getScript("js/desktop.js", function() { $desktop_load + 1; }); } else { } } if (window.innerWidth < 768) { if (window.innerWidth >= 768) { if (!$desktop_load) { // GET DESKTOP SCRIPT TO KEEP THINGS QUICK $.getScript("js/desktop.js", function() { $desktop_load + 1; }); } else { } } } }) .resize(); // trigger resize event }) Ty for future response. Edit - To give an example, in desktop.js i have a gif that loads before "abc" content, that gets inserted by .load(). On resize this gif will show up and the .load() in desktop.js will fire again. So if getScript was only being called once, it should not be doing anything again in desktop.js. Confusing?

    Read the article

  • Sending variable to $.getScript

    - by oshirowanen
    Is it possible to send a variable to the script loaded using $.getScript? At the moment I have: $.getScript( "js/my_script.js", function() { // do something here after script has loaded }); But I want to send a variable to the loaded script. Is this possible, if yes, how? For example // this is a variable set outside of the script loaded via `$.getScript` var my_variable = 1 // how do I get that variable sent to `my_script.js` $.getScript( "my_script.js", function() { // do something here after script has loaded });

    Read the article

  • jQuery getScript and Google Maps API Problem

    - by k0ni
    HI I got a problem with loading the google maps api. I got my own object with a function that initializes the map, and the google maps api gets loaded via jquery.getscript. but i always get an error message in the callback function: var MyGMap = { GMapScriptURL: "http://maps.google.com/maps?file=api&v=2&async=2&key=", Map: null, Geocoder: null, InitiazlizeMaps: function () { if (GBrowserIsCompatible()) { this.Map = new GMap2(document.getElementById("map_canvas")); this.Map.setCenter(new GLatLng(37.4419, -122.1419), 13); this.Geocoder = new GClientGeocoder(); } } } $(function(){ var CurrentKey = "MY_KEY"; $.getScript(MyGMap.GMapScriptURL + CurrentKey, function () { MyGMap.InitiazlizeMaps(); // throws GMap2 is undefined }); }); whats wrong? why is this not running?

    Read the article

  • Questions about jQuery's getScript()

    - by Nimbuz
    $.getScript("somescript.js", function() { alert('Load Complete'); }); Once loaded, is it cached or is it loaded again if referenced more than once? If an event depends on this file being loaded, will the event be delayed of fail/timeout in case the file takes longer to load or doesn't load? How do I check and do something in case the file fails to load for some reason? Thanks in advance for your help.

    Read the article

  • jQuery.getScript: data variable in callback undefined

    - by Hannes
    I'm trying to load an external JavaScript using jQuery's getScript(), like this: $.getScript("http://api.recaptcha.net/js/recaptcha_ajax.js", function(data) { window.alert(data); }); but as the alert window shows, the data variable in the callback function is undefined, unlike promised in http://docs.jquery.com/Ajax/jQuery.getScript#urlcallback. Anyone know why this might be? Thanks.

    Read the article

  • jQuery getScript function with frames

    - by user210099
    Hello.. I'm a novice at Javascript/Jquery programming, so an apology if this is a simple/silly question. I am trying to use the jQuery .getScript() function to refresh part of an existing webpage. This webpage must be run on a local file system, and a large amount of the formatting is done using frames. Right now, there’s three main frames- a sidebar which displays possible “scopes” to choose from, a main frame which displays the majority of the contents of the webpage, and a footer frame. The main entry into the page is in an index.html file, which loads a sidebar.html, main.html, and footer.html file into each of the respective frames. In turn, the main.html has a number of javascript files which it loads, the main being a main.js, which contains numerous functions to format/process the contents for this main window. After loading this javascript file, main.html loads a few javascript files, which contain the data which is going to be displayed in the main frame. These files that are loaded have a fixed data structure, and are dependent on the functions that were loaded by the main.js file. Loading the webpage works fine now, but when a user tries to switch to another “scope”, the whole webpage is reloaded to make the switch. The only difference in the webpage is the content in the main.js frame, loaded in by a different set of .js files. Enough text, let’s look at some code. When the webpage loads, I tried to add a simple call to the getScript function in a .js file at the index.html level which handles switching scopes. This file, newFile, has different data definitions than the previously loaded oldFile.js which was loaded in the main.html file. $.getScript(/js/newFile.js); However this doesn’t work, since newFile.js depends on a parseData() function which is in main.js. If I open firebug up, parseData is not located in the dom tab, which I assume is related to some scoping issue with the main.html and main.js file existing in a different frame. I tried to do some targeting to the correct “frame” but I don’t think I understand jQuery enough to know what is happening. $(window.parent.frames[0]).getScript(/js/newFile.js); Any suggestions? If I were to type into firebug console “parseData” it can not find it: “ReferenceError: parseData is not defined” However, if I type in window.parent.frames[1].parseData, it can find the function. Sorry about all the rambling and poor understanding of javascript. Hopefully someone can provide some assistance! Thanks

    Read the article

  • jquery getscript <script> tags

    - by user1871612
    To ask about getscript html Code as follows: <!DOCTYPE html PUBLIC "- / / W3C / / DTD XHTML 1.0 Transitional / / EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>jQuery GetScript</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script type = "text / javascript "> $(document). ready(function () { $getScript ('script.js', function (jd) { $.each (test, function (index, value) { console.log (value); }); }); }); </script> </head> <body> <div id="dest"> </div> </body> </html> js (1) code are as follows: - <script type='text/javascript'> var test = []; test [0] = ['111 ', '222']; </ script> js (2) Code as follows: - var test = []; test [0] = ['111 ', '222']; The problem is as follows: - Run js (1) code will appear: - Uncaught SyntaxError: Unexpected token < No problem running js (2) Would like to ask how we can run js (1) can not go wrong Thank! Badly written, please forgive me.

    Read the article

  • .getScript getting the redirect url of javascript

    - by user177883
    I d like to execute a remote javascript which redirects the user to another page on my domain with data that s passes as query string. I want to get this data which is passed on to the page on my domain. $.getScript('http://site.com/foo.js', function() { //foo.js redirects to another page on my domain with data // and i d like to capture that data from this function, // at least if i find the parameters that passed on there, i ll be fine. }); What to do ? http://api.jquery.com/jQuery.getScript/

    Read the article

  • JQuery, Load() contents with plugins

    - by Galas
    I know this is not a completely new question, but none of the answers solved my problem... I have built a little menu that uses load() to load image galleries (as external html files) into a specified div ("content"). The said galleries make use of a JQuery plugin (SlideJS). Now I know that load() does not work for script tags and that I need to use $.getscript in the callback function in order to run the scripts, but it does not work. I have two .js files that need to be loaded: one is the plugin itself and another one is a smaller script with a preloader and the animations for the captions. I can't seem to merge them together; if I put them into the same document, the script won't run. So I tried just using $.getscript to load the two files. I tried using two callbacks as suggested in other answer (I know it's not ideal...): $("#proposal").click(function(){ $(this).addClass('selected'); $("a:not(:#proposal)").removeClass('selected'); $("#content").load("works/proposal/proposal.html", function(){ $.getScript("js/slide.js", function (){ $.getScript("js/slidepage.js"); }); }); }); and I tried a variable (read about it in some other faq, not sure if the syntax is correct) $("#proposal").click(function(){ $(this).addClass('selected'); $("a:not(:#proposal)").removeClass('selected'); $("#content").load("works/proposal/proposal.html", function(){ var scripts = ['js/slide.js','js/slidepage.js']; $.getScript(scripts); }); }); So none of these work. What am I doing wrong? I'm just starting on jquery and my js knowledge is very limited. Should I just merge the two .js files together using minify or something? One of them is already minified, but I've tried with a non-minified version and it does not work either. Can anyone suggest any other solution around this problem? I thought of just having the div embedded in the main document and just showing it on click, but I'll have at least 4 galleries with about 8 to 10 images each... its a lot of images to load in the main page, so I don't think its the best way. if you need me to post any more code, please ask! Thanks in advance for all your help!

    Read the article

  • Jquery .getScript getting the redirect url of javascript

    - by user177883
    I d like to execute a remote javascript which redirects the user to another page on my domain with data that s passes as query string. I want to get this data which is passed on to the page on my domain. $.getScript('http://site.com/foo.js', function() { **//foo.js redirects to another page on my domain with data // and i d like to capture that data from this function, // at least if i find the parameters that passed on there, i ll be fine.** }); What to do ?

    Read the article

  • using getScript to import plugin on page using multiple versions of jQuery

    - by mikez302
    I am developing an app on a page that uses jQuery 1.2.6, but I would like to use jQuery 1.4.2 for my app. I really don't like to use multiple versions of jQuery like this but the copy on the page (1.2.6) is something I have no control over. I decided to isolate my code like this: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html><head> <script type="text/javascript" src="jquery-1.2.6.min.js> <script type="text/javascript" src="pageStuff.js"> </head> <body> Welcome to our page. <div id="app"> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script> <script type="text/javascript" src="myStuff.js"> </div> </body></html> The file myStuff.js has my own code that is supposed to use jQuery 1.4.2, and it looks like this: (function($) { //wrap everything in function to add ability to use $ var with noConflict var jQuery = $; //my code })(jQuery.noConflict(true)); This is an extremely simplified version, but I hope you get the idea of what I did. For a while, everything worked fine. However, I decided to want to use a jQuery plugin in a separate file. I tested it and it acted funny. After some experimentation, I found out that the plugin was using the old version of jQuery, when I wanted it to use the new version. Does anyone know how to import and run a js file from the context within the function wrapping the code in myStuff.js? In case this matters to anyone, here is how I know the plugin is using the old version, and what I did to try to solve the problem: I made a file called test.js, consisting of this line: alert($.fn.jquery); I tried referencing the file in a script tag the way external Javascript is usually included, below myStuff.js, and it came up as 1.2.6, like I expected. I then got rid of that script tag and put this line in myStuff.js: $.getScript("test.js"); and it still came back as 1.2.6. That wasn't a big surprise -- according to jQuery's documentation, scripts included that way are executed in the global context. I then tried doing this instead: var testFn = $.proxy($.getScript, this); testFn("test.js"); and it still came back as 1.2.6. After some tinkering, I found out that the "this" keyword referred to the window, which I assume means the global context. I am looking for something to put in place of "this" to refer to the context of the enclosing function, or some other way to make the code in the file run from the enclosing function. I noticed that if I copy and paste the code, it works fine, but it is a big plugin that is used in many places, and I would prefer not to clutter up my file with their code. I am out of ideas. Does anyone else know how to do this?

    Read the article

  • How do you make the script wait for the status of an Ajax get request before continuing?

    - by codeninja
    Basically what I'm doing is checking for the existence of an object, if it's not found, the script will try to load the source file using getScript. I only want to check this once though then return true or false to the function that calls fetch() fetch:function(obj){ ... isReady = false; $.getScript(obj.srcFile,function(){ isReady=true; warn("was able to load object "+key); }); return isReady; } but return kicks in before the script loads =/ later the script is loaded but the function returned false. This is the beauty of asynchronous I suppose... What's the best way to handle this... Maybe I could check again at some other point if the object exists? Or maybe there's a better way to do this where I dont have to potentially lock the browser?

    Read the article

  • Firebug is throwing a ' $( ' error?

    - by Kyle
    I am getting a strange error in Firebug, that I am not getting in Webkit. The error comes up as ' $( ' in firebug. Here's the code that is supposedly causing it to flip: $.getScript("http://kylehotchkiss.com/min/?g=packageHome", function() { $(".countdown").countdown({ until: new Date(2010, 6 - 1, 5), layout:'{dn} {dl}' }); }); The error isn't specific to the countdown script, it's just giving me an error trying to call any plugin I just loaded in firefox. Any ideas?

    Read the article

  • Using jQuery's $.getScript(), can I sense 304 Not Modified Headers?

    - by Tom
    I have an application (a widget) where I use $.getScript() on a 5 minute timer, loading a file every five minutes. I then take the contents of the file I just downloaded, and rebuild my page, so that my widget can update. Most of the time, however, the file is unchanged, and firebug displays a 304 Not Modified header every 5 minutes, as my timer executes $.getScript(). I would like to sense when the file is not modified, so that I don't use up user resources, rebuilding the page for no reason. Is it possible to obtain html headers when using $.getScript()?

    Read the article

  • jQuery's getScript and the local file system-- limitations/alternatives?

    - by user210099
    Right now I'm working on a help-system which is based on a local file system. It is intended to be shipped with a product which is not used on internet-enabled machines, so it must be a stand alone webpage, without any dependencies on a web server. This introduces a few challenges. Namely, the directory structure that the files exist in require navigating "up and over" to access some .js files which are required to display the help system. This use to be implemented using the jQuery getScript function, but I have ran into some problems using this on the local file system. At first glance, it seemed that if my webpage was being served out of the C:/dev/webpage/html/ directory, and the files I needed were in C:/dev/webpage/js/(topic)/file.js, I could just build an absolute path (file:///...) and pass that into the getScript function. However, after testing this, it does not seem that the getScript function will let me go up a level from the html directory (where the html file is located which has the main code for the webpage). Unfortunately, I can not change the directory structure, nor can I change the .js file structure/format. Is there an alternative for loading/executing javascript files that are in a file structure where I need to go "up and over"? Thanks,

    Read the article

  • Jquery loaded? Colorbox is available? Calling some js file via $.getScript are always downloading fr

    - by uzay95
    I am dynamically load js files with _tumIsler.js (_allStuff.js) <script src="../js/_tumJsler.js" type="text/javascript"></script> It contains: // url=> http: + // + localhost:4399 + /yabant/ // ---- ---- -------------- -------- // protocol + "//" + host + '/virtualDirectory/' var baseUrl = document.location.protocol + "//" + document.location.host + '/yabant/'; // If there is "~/" at the begining of url, replace it with baseUrl function ResolveUrl(url) { if (url.indexOf("~/") == 0) { url = baseUrl + url.substring(2); } return url; } // Attaching scripts to any tag function addJavascript(jsname, pos) { var th = document.getElementsByTagName(pos)[0]; var s = document.createElement('script'); s.setAttribute('type', 'text/javascript'); s.setAttribute('src', jsname); th.appendChild(s); } // I want to make sure jQuery is loaded? addJavascript(ResolveUrl('~/js/1_jquery-1.4.2.min.js'), 'head'); var loaded = false; // assume it didn't first and if it is change it to true function fControl() { // alert("JQUERY is loaded?"); if (typeof jQuery == 'undefined') { loaded = false; fTry2LoadJquery(); } else { loaded = true; fGetOtherScripts(); } } // Check is jQuery loaded fControl(); function fTry2LoadJquery() { // alert("JQUERY didn't load! Trying to reload..."); if (loaded == false) { setTimeout("fControl()", 1000); } else { return; } } function getJavascript(jsname, pos) { // I want to retrieve every script one by one $.ajaxSetup({ async: false, beforeSend: function() { $.ajaxSetup({ async: false, cache: true }); }, complete: function() { $.ajaxSetup({ async: false, cache: true }); }, success: function() { // } }); $.getScript(ResolveUrl(jsname), function() { /* ok! */ }); } function fGetOtherScripts() { // alert("Other js files will be load in this function"); getJavascript(ResolveUrl('~/js/5_json_parse.js'), 'head'); getJavascript(ResolveUrl('~/js/3_jquery.colorbox-min.js'), 'head'); getJavascript(ResolveUrl('~/js/4_AjaxErrorHandling.js'), 'head'); getJavascript(ResolveUrl('~/js/6_jsSiniflar.js'), 'head'); getJavascript(ResolveUrl('~/js/yabanYeni.js'), 'head'); getJavascript(ResolveUrl('~/js/7_ResimBul.js'), 'head'); getJavascript(ResolveUrl('~/js/8_HaberEkle.js'), 'head'); getJavascript(ResolveUrl('~/js/9_etiketIslemleri.js'), 'head'); getJavascript(ResolveUrl('~/js/bugun.js'), 'head'); getJavascript(ResolveUrl('~/js/yaban.js'), 'head'); getJavascript(ResolveUrl('~/embed/bitgravity/functions.js'), 'head'); } After all these js files are loaded, this line is executing to show UploadFile page inside the page when clicked to the button which id is "btnResimYukle" . <script type="text/javascript"> if (jQuery().colorbox) { alert("colorbox exists"); } else { alert("colorbox doesn't exist"); $.ajaxSetup({ cache: true, async: false }); $.getScript(ResolveUrl('~/js/3_jquery.colorbox-min.js'), function() { alert("Loaded ! "); $('#btnResimYukle').live('click', function() { $.fn.colorbox({ iframe: true, width: 700, height: 600, href: ResolveUrl('~/Yonetim/DosyaYukle.aspx') }); return false; }); }); } </script> First i want to ask you very good people, i am always calling js files with $.getScript function. Are they always downloading in every $.getScript requests? And if it is so, how can i prevent that? is this work: $.ajaxSetup({ cache: true, async: false }); Second, i am always getting this error when i press F5 or Ctrl+F5 : But when i press enter key on url, there is no error :s

    Read the article

  • Any way to identify a redirect when using jQuery's $.ajax() or $.getScript() methods?

    - by Bungle
    Within my company's online application, we've set up a JSONP-based API that returns some data that is used by a bookmarklet I'm developing. Here is a quick test page I set up that hits the API URL using jQuery's $.ajax() method: http://troy.onespot.com/static/3915/index.html If you look at the requests using Firebug's "Net" tab (or the like), you'll see that what's happening is that the URL is requested successfully, but since our app redirects any unauthorized users to a login page, the login page is also requested by the browser and seemingly interpreted as JavaScript. This inevitably causes an exception since the login page is HTML, not JavaScript. Basically, I'm looking for any sort of hook to determine when the request results in a redirect - some way to determine if the URL resolved to a JSONP response (which will execute a method I've predefined in the bookmarklet script) or if it resulted in a redirect. I tried wrapping the $.ajax() method in a try {} catch(e) {} block, but that doesn't trap the exception, I'm assuming because the requests were successful, just not the parsing of the login page as JavaScript. Is there anywhere I could use a try {} catch(e) {} block, or any property of $.ajax() that might allow me to hone in on the exception or otherwise determine that I've been redirected? I actually doubt this is possible, since $.getScript() (or the equivalent setup of $.ajax()) just loads a script dynamically, and can't inspect the response headers since it's cross-domain and not truly AJAX: http://api.jquery.com/jQuery.getScript/ My alternative would be to just fire off the $.ajax() for a period of time until I either get the JSONP callback or don't, and in the latter case, assume the user is not logged in and prompt them to do so. I don't like that method, though, since it would result in a lot of unnecessary requests to the app server, and would also pile up the JavaScript exceptions in the meantime. Thanks for any suggestions!

    Read the article

  • Jscript help? What is the main purpose of this Javascript?

    - by user577363
    Dear All, I don't know Javascript, can you please show me the main purpose of this Javascript? Many Thanks!! <script> var QunarUtil=new function(){var prefix='/scripts/';var suffix='';var host='';if(location.host.indexOf('src.')!=-1){prefix='/scripts/src/';host='http://hstatic.qunar.com';suffix='.js';}else if(location.host.indexOf('enc.')!=-1){prefix='/scripts/';host='http://hstatic.qunar.com';suffix='.js';}else if(location.host.substring(0,10)=='sdev-'){prefix=location.host.substring(5,location.host.indexOf('.'));prefix='/'+prefix.replace(/\-/ig,'/');host='http://hstatic.qunar.com';suffix='.js';}else if(location.host.indexOf("h.qunar.com")!=-1){host='http://hstatic.qunar.com';suffix='';} this.getScriptURL=function(name,isList){if(name.charAt(0)!='/') return this.getScript(prefix+name,isList);else return this.getScript(name,isList);} this.getScript=function(src,isList){return'<'+'script type="text/javascript" src="'+host+src+(isList?suffix:'.js')+'?'+__QUNARVER__+'"></'+'script>';} this.writeScript=function(name,isList){document.write(this.getScriptURL(name,isList));} this.writeScriptList=function(list){for(var i=0;i<list.length;i++) document.write(this.getScriptURL(list[i]));} var cssRoot='/styles/';this.writeCSS=function(cssList){for(var i=0;i<cssList.length;i++){document.write('<link rel="stylesheet" href="'+cssRoot+cssList[i]+'?'+__QUNARVER__+'">');}} this.writeStaticScript=function(src){document.write('<scr'+'ipt type="text/javascript" src="'+src+'"></'+'scr'+'ipt>');} this.writeStaticList=function(src){document.write('<scr'+'ipt type="text/javascript" src="'+src+suffix+'?'+__QUNARVER__+'"></'+'scr'+'ipt>');}} $include=function(){for(var i=0;i<arguments.length;i++){QunarUtil.writeScript(arguments[i],true);}} </script> Uncompressed version: <script> var QunarUtil = new function() { var prefix = '/scripts/'; var suffix = ''; var host = ''; if (location.host.indexOf('src.') != -1) { prefix = '/scripts/src/'; host = 'http://hstatic.qunar.com'; suffix = '.js'; } else if (location.host.indexOf('enc.') != -1) { prefix = '/scripts/'; host = 'http://hstatic.qunar.com'; suffix = '.js'; } else if (location.host.substring(0, 10) == 'sdev-') { prefix = location.host.substring(5, location.host.indexOf('.')); prefix = '/' + prefix.replace(/\-/ig, '/'); host = 'http://hstatic.qunar.com'; suffix = '.js'; } else if (location.host.indexOf("h.qunar.com") != -1) { host = 'http://hstatic.qunar.com'; suffix = ''; } this.getScriptURL = function(name, isList) { if (name.charAt(0) != '/') return this.getScript(prefix + name, isList); else return this.getScript(name, isList); } this.getScript = function(src, isList) { return '<' + 'script type="text/javascript" src="' + host + src + (isList ? suffix : '.js') + '?' + __QUNARVER__ + '"></' + 'script>'; } this.writeScript = function(name, isList) { document.write(this.getScriptURL(name, isList)); } this.writeScriptList = function(list) { for (var i = 0; i < list.length; i++) document.write(this.getScriptURL(list[i])); } var cssRoot = '/styles/'; this.writeCSS = function(cssList) { for (var i = 0; i < cssList.length; i++) { document.write('<link rel="stylesheet" href="' + cssRoot + cssList[i] + '?' + __QUNARVER__ + '">'); } } this.writeStaticScript = function(src) { document.write('<scr' + 'ipt type="text/javascript" src="' + src + '"></' + 'scr' + 'ipt>'); } this.writeStaticList = function(src) { document.write('<scr' + 'ipt type="text/javascript" src="' + src + suffix + '?' + __QUNARVER__ + '"></' + 'scr' + 'ipt>'); } } $include = function() { for (var i = 0; i < arguments.length; i++) { QunarUtil.writeScript(arguments[i], true); } } </script>

    Read the article

  • call .js file after ajax load

    - by asovgir
    I am trying to apply a .js file to a page I loaded via ajax (since ajax automatically strips the content of all the javascript). var url; var textUrl = 'local/file.js'; $('a').click(function() { url = $(this).attr('href'); $('.secondaryDiv').load(url, function() { $.getScript(textUrl, function(data, textStatus, jqxhr) { console.log(data); //data returned from getScript console.log(textStatus); //return "success" console.log(jqxhr.status); //200 }); }); return false; }); Am I approaching this the right way? I tried everything I could think of and I can't get it to work

    Read the article

  • How would one dynamically load Javascript that has been parsed as PHP?

    - by beatsforthemind
    I am looking to dynamically load javascript that has been parsed as PHP so that I will be able to pass PHP variables to javascript, and then load this file into the primary PHP document. I have a document called myscript.js.php that includes the javascript and PHP. I attempted to load it into the primary document using jQuery's getScript like this: $.getScript("myscript.js.php", function() { alert('loaded script.'); }); This attempt failed - I am assuming because of the .php extension on the file. Is there anyway to dynamically load javascript that includes PHP? I have a few session variables that I am looking to pass through javascript that will be updated frequently, creating a need for the javascript to be reloaded.

    Read the article

1 2 3  | Next Page >