jquery-get

How to get jQuery ajax calls to work from greasemonkey page events

半世苍凉 提交于 2019-12-24 00:51:55
问题 I have a GM script which inserts a link on to the page, and then adds an event listener for when its clicked. This then runs a function which contains among other things some jQuery.get calls. These calls however do not seem to fire unless I use the unsafeWindow version of jQuery. function runMyFunc() { console.log('myFunc is called'); $.get('index.php',function () { console.log('jQuery.get worked'); }); } $("#someHook").before('<a id="myLink">Link</a>'); $('#myLink').click(runMyFunc); The

Store ajax result in jQuery variable

主宰稳场 提交于 2019-12-18 17:24:08
问题 I started using jQuery and ajax to get data from database, but i cant find out how i can save result of $.get() into variable outside callback function. This is my jquery script: var result=""; $.get("test.php", function(data){ result=data; }); alert(result); This is test.php script: echo "Hello, World"; Every time i run this script it alerts "". 回答1: Try this: var result = ""; $.get("test.php", function (data) { SomeFunction(data); }); function SomeFunction(data) { result = data; alert

Does jQuery's $.getScript behave differently in Firefox ? It's not executing the script after loading it, Chrome is doing fine

这一生的挚爱 提交于 2019-12-13 00:18:36
问题 The following code $.getScript("/js/dygraph-combined.js") .done(function(script, textStatus) { console.log(Dygraph); }) .fail(function(jqxhr, settings, exception) { console.error('it failed to load'); }); yields Dygraph is not defined in Firefox 11.0, and [Dygraph 1.2] on Chrome 17.0.963.83. So it seems that the script loads on both browsers but doesn't get executed in Firefox 11... Why would that be ? How do I get this behaving like it should ? This script is Dygraph and from it's website it

serialize javascript array

房东的猫 提交于 2019-12-12 02:56:46
问题 I am using the dojo enhanced grid and the variable marked "myGrid" refers to the grid. function addtocart() { $("#additem").click(function(){ var myGrid = dojo.byId(dataGrid); var ids = []; var gridRow = myGrid.selection.getSelected(); $.each( gridRow, function(i, l){ ids.push(l.id); }); var registcarturl = "${carturl}" + $("#regCart :selected").val(); $.get(registcarturl, {instanceIds: ids}, function(data) { alert(data); }); }); } I am not sure what the string for a serialized array should

JQuery .get doesnt execute Javascript

佐手、 提交于 2019-12-02 07:01:46
问题 I am using JQuery .get method to retrieve some content from a webpage (page 1) and show it in a div in the main page. The problem is the content retrieved contains some javascript calls. The content is being displayed, but the Javascript methods are not getting executed . The .js file is being referenced across all the pages, so the availability of the js in the main is not a problem. This is the code in the main page. URL of page 1 is given to the .get function: $.get(url, function(response)

JQuery .get doesnt execute Javascript

寵の児 提交于 2019-12-01 23:36:09
I am using JQuery .get method to retrieve some content from a webpage (page 1) and show it in a div in the main page. The problem is the content retrieved contains some javascript calls. The content is being displayed, but the Javascript methods are not getting executed . The .js file is being referenced across all the pages, so the availability of the js in the main is not a problem. This is the code in the main page. URL of page 1 is given to the .get function: $.get(url, function(response) { var newContent = $(response).find("#right"); //Find the content section of the response var