getscript

Jquery getScript($.getScript()) not working on chrome?

走远了吗. 提交于 2019-12-24 23:06:45
问题 I have a problem using $.getScript() on chrome. It doesn't work on chrome browser. I've tested it on firefox, ie and safari and it worked. All I have on my external script is an alert() and it doesn't work. Here's the code: page $(document).ready(function(){ $("#btnGet").click(function(){ $.getScript("script.js"); }); }); script.js alert('Get script loading'); Is anyone have experienced this problem? 回答1: Thanks guys for making it clear to me. I think I would have my script inline instead

Using resize to getScript if above x pixels (jQuery)

喜你入骨 提交于 2019-12-24 21:17:47
问题 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

jQuery getScript method's internal process

妖精的绣舞 提交于 2019-12-23 12:34:54
问题 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 of loaded scripts by getScript in the DOM . So how does jQuery execute loaded scripts without script tag references in the DOM? $.getScript('gallery.js') is exactly same thing with $('<script src="gallery.js">').appendTo('body') ? 回答1: This is the

How to delete script loaded by .getScript()

懵懂的女人 提交于 2019-12-21 13:08:06
问题 When I load a script with .getScript('file.js') is there a way to do remove that script later? sort of like a clean where I say delete the js I loaded earlier 回答1: getScript doesn't "load" a script in the sense of keeping it around; it downloads the script from the server and runs it immediately. So there's no need to remove it. However, any DOM objects that the script creates, or functions it defines, etc., will continue to exist. Removing these will require knowing specifically what they

How to getScript only once

穿精又带淫゛_ 提交于 2019-12-13 16:29:32
问题 So this is a simplified question of this ( which im using for reference, to make this question easy...) Using resize to getScript if above x pixels (jQuery) If I call for a function that gets a script, to, if that function fires again, it will not load the script again. Which in ^ that code it is. getScript - How to only call if not already called Is an example, but i tried that code awhile ago. EX: $(function() { var gotscript=false; $(window).resize(function() { //Dekstop if (window

jquery script request not caching

早过忘川 提交于 2019-12-12 04:19:15
问题 I am trying to cache a very simple javascript response. I am using rails and my views/projects/index.js.erb contains only the following: alert('hi'); and when I request $.ajax({ type: 'GET', cache: true, url : '/projects', dataType: 'script' }); I get the popup 'hi' and I see in my server log that a request to Projects#index action as js has been made to it. Then without refreshing the browser and I do it again $.ajax({ type: 'GET', cache: true, url : '/projects', dataType: 'script' }); I see

jQuery $.getScript - old functions & variables in executed script

流过昼夜 提交于 2019-12-11 15:42:41
问题 i execute a javascript with jQuery $.getScript. In the executed script i haven't access to the functions and variables of my source file. Is there a solution? 回答1: The script executed by $.getScript() does have access to the global context. You can use any global variable (or function for that matter) from within your external script. 回答2: Nick Craver, I just spend 3 (!) hours obsessing over why my thing wouldn't work, and you gave me the insight I needed to make it work. XOXOXOXOXOXOXOXO

getScript stopped working

爱⌒轻易说出口 提交于 2019-12-11 07:35:42
问题 To speed up the load time of our site, we defer the loading of some scripts. This has been working fine until a couple of days ago. I've boiled the issue down to this short page of HTML. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js"> </script> <script type="text

Make $.getScript(“”) not add numbers at the end of the request

你离开我真会死。 提交于 2019-12-11 04:39:20
问题 I am using $.getScript() to get a script from somewhere. function fetch(url){ window.setInterval(function (){ $.getScript(url); },50000) } fetch("http://example.com/script.js"); However, when I look at the FireBug developer console, I have seen that it adds additional ?numbers. Here is the output: <script async="" src="http://example.com/script.js?7330519448833367000&_=1416681336440"> The remote server has disabled the ? char from their htaccess. I need to use $.getScript("") to get the

Having difficulty working with global variables and $.getScript

跟風遠走 提交于 2019-12-11 01:37:34
问题 I have the following script which does not work properly: function getWidgetContent( widget ) { if(widget.script!=null){ $global_widget_id = widget.widget_id; $.getScript( "js/" + widget.script, function() { $( ".widget_header_title_" + widget.widget_id ).append( widget.title ); }); } } This is called as follows: for ( j = 0; j <= widget_data.d.length - 1; j++ ) { getWidgetContent( widget_data.d[j] ); } I thought this would run the function, within the function, assign a value to the global