Questions tagged [getscript]

188 questions
5
votes
2 answers

jQuery getScript method's internal process

I am trying to understand the internal process of getScript. I am aware that it uses $.get method interally.I was thinking that jQuery puts a script tag reference into the DOM for being able execute that js file but I couldn't find script references…
Freshblood
  • 6,285
  • 10
  • 59
  • 96
5
votes
3 answers

When using jQuery's getScript() function I get a "not well-formed" error on a line with comments

My guess is that the src file needs to be XML-friendly, but of course none of the JS file is since it's using all sorts of non-XML compliant entities. getScript() may be expecting an XML file =/ Any thoughts? if(is_def(pObj)){ …
qodeninja
  • 10,946
  • 30
  • 98
  • 152
5
votes
3 answers

"use strict"; + jQuery.getScript() = script can't export to global namespace

Suppose I have the following script, called include_strict.js. After it executes I should have window.global1 defined: "use strict"; var globalVar = {}; alert(typeof window.globalVar); But if I include it from a block of javascript…
mxxk
  • 9,514
  • 5
  • 38
  • 46
4
votes
1 answer

jQuery's .getScript()... what am I doing wrong?

I'm programming an iPhone app with Phonegap. I have local .html and .js files. The following is in my index.html file: function onBodyLoad() { document.addEventListener("deviceready", deviceReady, false); } function deviceReady() { …
In Lee
  • 41
  • 2
4
votes
1 answer

Add additional data to getScript jQuery function

I want to inject script like this using jQuery getScript function I want to add that extra variable with its value which…
Hunter
  • 459
  • 4
  • 15
4
votes
1 answer

getScript creates ReferenceError

I have some js scripts that I load into my main.js before I start the rest of my code. However during testing it came to my attention that sometimes it creates the following reference error (1 in 8 pageloads or something). ReferenceError:…
4
votes
2 answers

Questions about jQuery's getScript()

$.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…
eozzy
  • 66,048
  • 104
  • 272
  • 428
4
votes
2 answers

Can getscript run imported scripts in jquery noconflict?

Say I am running a version of jQuery in no conflict like this: And I had an external…
user2062244
  • 113
  • 2
  • 11
4
votes
3 answers

Sending variable to $.getScript

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…
oshirowanen
  • 15,297
  • 82
  • 198
  • 350
4
votes
6 answers

jQuery getScript vs Embedding Script in File

I was wondering whether use jquery´s getScript or not. I have a jQuery plugin that I need to include in my site, but I am unsure what to do and I am wondering if there is a difference between these approaches: In my case, I have to include a rather…
r0skar
  • 8,338
  • 14
  • 50
  • 69
3
votes
1 answer

$.getScript returns status canceled and the application does not execute the callback function?

Environment To automate the compression and the junction of my js files, I use this tool. Once installed and configured, the code below returns a js compressed and concatenated with all the JS folder project
ridermansb
  • 10,779
  • 24
  • 115
  • 226
3
votes
2 answers

jQuery. How to execute script loaded from JSON?

I have file like this: {'html' : '
something
', 'script' : ' $().ready(function() { /* some code */});' } I need to load it with jQuery and execute the 'script' variable. I know about $.getScript, but I need to run the script not…
Taras Bulgakov
  • 543
  • 3
  • 11
  • 21
3
votes
3 answers

Resetting document.ready ($.getScript)

I need to include a script via $.getScript dynamically. The problem is however, that the $(document).ready function from that dynamically included script is not executed. (They dynamic insertion does not happen at dom ready) Is there some way to…
user429620
3
votes
2 answers

$getScript Method to load google maps api -> blank page?

I have a little button on my page that should load a google map. Since I want my page to load really fast and this feature is not actually necessary I don't want to embed the google maps API script on page-load. I just want to load it when the…
matt
  • 42,713
  • 103
  • 264
  • 397
3
votes
1 answer

'SyntaxError: expected expression, got <' from $.getScript

I want to create a jQuery multilingual plugin. I also want to open the language files containing the "object" inside my plugin function and access its content. $.getScript('lang/' + settings.language + '.js').done(function() { console.log('loaded…
ali tajari
  • 25
  • 3
1
2
3
12 13