Fwd: [jQuery] Re: getJSON callback not firing?
Begin forwarded message: From: Igor Romero phiberga...@gmail.com Date: September 26, 2009 AM 04:22:07 GMT+08:00 To: jquery-en@googlegroups.com Subject: Re: [jQuery] Re: getJSON callback not firing? can try this out function ajaxSucceed(result){ alert(result.d); } function ajaxFailed() { alert(Failed); } function makeAjax(){ $.ajax({ type: POST, url: SampleService.asmx/yourMethod, contentType: application/json; charset=utf-8, data: {}, dataType: json, success: ajaxSucceed, error: ajaxFailed }); } On 26-Sep-2009, at 3:13 AM, MorningZ wrote: $.getJSON is a convenience/wrapper method around the $.ajax call... so is $.getScript and $.get and $.post just open up the unpacked version of jQuery and search for getJSON and you'll see this first hand On Sep 25, 3:07 pm, Charlie Griefer charlie.grie...@gmail.com wrote: Z: thanks for the response. I'm making my initial foray into using jQuery for AJAX (up 'til now, had only used it for page manipulations). Given your response... would there ever be a situation where .getJSON() would be preferable to .ajax()? It seems odd that jQuery would have 2 methods that essentially do the same thing. Especially if one is near impossible to debug. Thanks, Charlie On Fri, Sep 25, 2009 at 11:58 AM, MorningZ morni...@gmail.com wrote: I'd suggest using the more generic $.ajax method so you can actually catch the error, as the $.getJSON fails silently, which is no good for programmers :-( $.ajax({ type: GET, url: your URL, processData = true, data: {}, dataType: json, success: function(json) { alert(success); }, error: function(x,y,z) { // x.responseText should have what's wrong } }); On Sep 25, 2:06 pm, Charlie Griefer charlie.grie...@gmail.com wrote: Hey all: I've read the docs and googled the heck out of this, but not seeing what the problem is. I'm trying to get some data from the server via the getJSON() method. I do see a response in firebug and I've validated the response data at JSONLint.com. However, the callback function simply will not fire. I've tried to simplify things as much as possible. The CFC returning the data is in the same directory as the calling page. The callback function, for now, should only alert a simple text string (which has evolved from hi to foo to a censored version below as the hours have passed). $(document).ready(function() { $('a.players').click(function() { $.getJSON( 'data.cfc? method =getPlayerByIDreturnformat=JSONqueryformat=columnplayerID=' + this.id, function(data) { alert('i %!%##%* hate you'); }); return false; }); }); Here's the response I receive: {ROWCOUNT:1,COLUMNS: [PLAYERID ,PLAYERNAME ,PLAYERNUMBER ,PLAYERPOSITION,PLAYERIMG,PLAYERCOLLEGE],DATA: {PlayerID:[1],PlayerName:[Barden, Ramses],PlayerNumber:[13],PlayerPosition:[WR],PlayerImg: [http:\/\/ assets.giants.com \/uploads\/players\/ 2FE2D3BDF4FB443D949D1D39B69ADC03.gif],PlayerCollege:[Cal Poly]}} ...which when pasted into JSONLint returns valid. If anyone has any ideas, or if there's any additional information that I can provide, I'm all ears. Thanks! Charlie -- Charlie Grieferhttp://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success. -- Charlie Grieferhttp://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: getJSON callback not firing?
I'd suggest using the more generic $.ajax method so you can actually catch the error, as the $.getJSON fails silently, which is no good for programmers :-( $.ajax({ type: GET, url: your URL, processData = true, data: {}, dataType: json, success: function(json) { alert(success); }, error: function(x,y,z) { // x.responseText should have what's wrong } }); On Sep 25, 2:06 pm, Charlie Griefer charlie.grie...@gmail.com wrote: Hey all: I've read the docs and googled the heck out of this, but not seeing what the problem is. I'm trying to get some data from the server via the getJSON() method. I do see a response in firebug and I've validated the response data at JSONLint.com. However, the callback function simply will not fire. I've tried to simplify things as much as possible. The CFC returning the data is in the same directory as the calling page. The callback function, for now, should only alert a simple text string (which has evolved from hi to foo to a censored version below as the hours have passed). $(document).ready(function() { $('a.players').click(function() { $.getJSON( 'data.cfc?method=getPlayerByIDreturnformat=JSONqueryformat=columnplayerID=' + this.id, function(data) { alert('i %!%##%* hate you'); }); return false; }); }); Here's the response I receive: {ROWCOUNT:1,COLUMNS:[PLAYERID,PLAYERNAME,PLAYERNUMBER,PLAYERPOSITION,PLAYERIMG,PLAYERCOLLEGE],DATA:{PlayerID:[1],PlayerName:[Barden, Ramses],PlayerNumber:[13],PlayerPosition:[WR],PlayerImg:[http:\/\/ assets.giants.com\/uploads\/players\/2FE2D3BDF4FB443D949D1D39B69ADC03.gif],PlayerCollege:[Cal Poly]}} ...which when pasted into JSONLint returns valid. If anyone has any ideas, or if there's any additional information that I can provide, I'm all ears. Thanks! Charlie -- Charlie Grieferhttp://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: getJSON callback not firing?
Z: thanks for the response. I'm making my initial foray into using jQuery for AJAX (up 'til now, had only used it for page manipulations). Given your response... would there ever be a situation where .getJSON() would be preferable to .ajax()? It seems odd that jQuery would have 2 methods that essentially do the same thing. Especially if one is near impossible to debug. Thanks, Charlie On Fri, Sep 25, 2009 at 11:58 AM, MorningZ morni...@gmail.com wrote: I'd suggest using the more generic $.ajax method so you can actually catch the error, as the $.getJSON fails silently, which is no good for programmers :-( $.ajax({ type: GET, url: your URL, processData = true, data: {}, dataType: json, success: function(json) { alert(success); }, error: function(x,y,z) { // x.responseText should have what's wrong } }); On Sep 25, 2:06 pm, Charlie Griefer charlie.grie...@gmail.com wrote: Hey all: I've read the docs and googled the heck out of this, but not seeing what the problem is. I'm trying to get some data from the server via the getJSON() method. I do see a response in firebug and I've validated the response data at JSONLint.com. However, the callback function simply will not fire. I've tried to simplify things as much as possible. The CFC returning the data is in the same directory as the calling page. The callback function, for now, should only alert a simple text string (which has evolved from hi to foo to a censored version below as the hours have passed). $(document).ready(function() { $('a.players').click(function() { $.getJSON( 'data.cfc?method=getPlayerByIDreturnformat=JSONqueryformat=columnplayerID=' + this.id, function(data) { alert('i %!%##%* hate you'); }); return false; }); }); Here's the response I receive: {ROWCOUNT:1,COLUMNS:[PLAYERID,PLAYERNAME,PLAYERNUMBER,PLAYERPOSITION,PLAYERIMG,PLAYERCOLLEGE],DATA:{PlayerID:[1],PlayerName:[Barden, Ramses],PlayerNumber:[13],PlayerPosition:[WR],PlayerImg:[http:\/\/ assets.giants.com \/uploads\/players\/2FE2D3BDF4FB443D949D1D39B69ADC03.gif],PlayerCollege:[Cal Poly]}} ...which when pasted into JSONLint returns valid. If anyone has any ideas, or if there's any additional information that I can provide, I'm all ears. Thanks! Charlie -- Charlie Grieferhttp://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success. -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: getJSON callback not firing?
$.getJSON is a convenience/wrapper method around the $.ajax call... so is $.getScript and $.get and $.post just open up the unpacked version of jQuery and search for getJSON and you'll see this first hand On Sep 25, 3:07 pm, Charlie Griefer charlie.grie...@gmail.com wrote: Z: thanks for the response. I'm making my initial foray into using jQuery for AJAX (up 'til now, had only used it for page manipulations). Given your response... would there ever be a situation where .getJSON() would be preferable to .ajax()? It seems odd that jQuery would have 2 methods that essentially do the same thing. Especially if one is near impossible to debug. Thanks, Charlie On Fri, Sep 25, 2009 at 11:58 AM, MorningZ morni...@gmail.com wrote: I'd suggest using the more generic $.ajax method so you can actually catch the error, as the $.getJSON fails silently, which is no good for programmers :-( $.ajax({ type: GET, url: your URL, processData = true, data: {}, dataType: json, success: function(json) { alert(success); }, error: function(x,y,z) { // x.responseText should have what's wrong } }); On Sep 25, 2:06 pm, Charlie Griefer charlie.grie...@gmail.com wrote: Hey all: I've read the docs and googled the heck out of this, but not seeing what the problem is. I'm trying to get some data from the server via the getJSON() method. I do see a response in firebug and I've validated the response data at JSONLint.com. However, the callback function simply will not fire. I've tried to simplify things as much as possible. The CFC returning the data is in the same directory as the calling page. The callback function, for now, should only alert a simple text string (which has evolved from hi to foo to a censored version below as the hours have passed). $(document).ready(function() { $('a.players').click(function() { $.getJSON( 'data.cfc?method=getPlayerByIDreturnformat=JSONqueryformat=columnplayerID=' + this.id, function(data) { alert('i %!%##%* hate you'); }); return false; }); }); Here's the response I receive: {ROWCOUNT:1,COLUMNS:[PLAYERID,PLAYERNAME,PLAYERNUMBER,PLAYERPOSITION,PLAYERIMG,PLAYERCOLLEGE],DATA:{PlayerID:[1],PlayerName:[Barden, Ramses],PlayerNumber:[13],PlayerPosition:[WR],PlayerImg:[http:\/\/ assets.giants.com \/uploads\/players\/2FE2D3BDF4FB443D949D1D39B69ADC03.gif],PlayerCollege:[Cal Poly]}} ...which when pasted into JSONLint returns valid. If anyone has any ideas, or if there's any additional information that I can provide, I'm all ears. Thanks! Charlie -- Charlie Grieferhttp://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success. -- Charlie Grieferhttp://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: getJSON callback not firing?
Hang in there, Charlie! My head was very bloody from banging it against the wall when I first started down the AJAX road. Now I'm finally getting some work done with it! I almost gave up several times. fwiw, I have always used the $.ajax method without any problems and typically specify the method as post, occasionally venturing to use get when just retrieving data, just to see what might happen.nothing different. (and actually, I recognized that censored expression, having been there! :o) Rick From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of Charlie Griefer Sent: Friday, September 25, 2009 2:06 PM To: jQuery (English) Subject: [jQuery] getJSON callback not firing? Hey all: I've read the docs and googled the heck out of this, but not seeing what the problem is. I'm trying to get some data from the server via the getJSON() method. I do see a response in firebug and I've validated the response data at JSONLint.com. However, the callback function simply will not fire. I've tried to simplify things as much as possible. The CFC returning the data is in the same directory as the calling page. The callback function, for now, should only alert a simple text string (which has evolved from hi to foo to a censored version below as the hours have passed). $(document).ready(function() { $('a.players').click(function() { $.getJSON( 'data.cfc?method=getPlayerByIDreturnformat=JSONqueryformat=columnplayerID =' + this.id, function(data) { alert('i %!%##%* hate you'); }); return false; }); }); Here's the response I receive: {ROWCOUNT:1,COLUMNS:[PLAYERID,PLAYERNAME,PLAYERNUMBER,PLAYERPOSIT ION,PLAYERIMG,PLAYERCOLLEGE],DATA:{PlayerID:[1],PlayerName:[Bard en, Ramses],PlayerNumber:[13],PlayerPosition:[WR],PlayerImg:[http:\/\/ assets.giants.com\/uploads\/players\/2FE2D3BDF4FB443D949D1D39B69ADC03.gif], PlayerCollege:[Cal Poly]}} ...which when pasted into JSONLint returns valid. If anyone has any ideas, or if there's any additional information that I can provide, I'm all ears. Thanks! Charlie -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: getJSON callback not firing?
the method as post, occasionally venturing to use get when just retrieving data, just to see what might happen.nothing different. Wow, really? knowing the difference between GET an POST are pretty fundamental things to know as a programmer http://www.google.com/search?q=get+vs+post It's very important to understand the difference as browsers (mainly IE) have issues with GET in some cases, and all browsers handle caching differently between the two On Sep 25, 6:28 pm, Rick Faircloth r...@whitestonemedia.com wrote: Hang in there, Charlie! My head was very bloody from banging it against the wall when I first started down the AJAX road. Now I'm finally getting some work done with it! I almost gave up several times. fwiw, I have always used the $.ajax method without any problems and typically specify the method as post, occasionally venturing to use get when just retrieving data, just to see what might happen.nothing different. (and actually, I recognized that censored expression, having been there! :o) Rick From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of Charlie Griefer Sent: Friday, September 25, 2009 2:06 PM To: jQuery (English) Subject: [jQuery] getJSON callback not firing? Hey all: I've read the docs and googled the heck out of this, but not seeing what the problem is. I'm trying to get some data from the server via the getJSON() method. I do see a response in firebug and I've validated the response data at JSONLint.com. However, the callback function simply will not fire. I've tried to simplify things as much as possible. The CFC returning the data is in the same directory as the calling page. The callback function, for now, should only alert a simple text string (which has evolved from hi to foo to a censored version below as the hours have passed). $(document).ready(function() { $('a.players').click(function() { $.getJSON( 'data.cfc?method=getPlayerByIDreturnformat=JSONqueryformat=columnplayerID =' + this.id, function(data) { alert('i %!%##%* hate you'); }); return false; }); }); Here's the response I receive: {ROWCOUNT:1,COLUMNS:[PLAYERID,PLAYERNAME,PLAYERNUMBER,PLAYERPOSIT ION,PLAYERIMG,PLAYERCOLLEGE],DATA:{PlayerID:[1],PlayerName:[Bard en, Ramses],PlayerNumber:[13],PlayerPosition:[WR],PlayerImg:[http:\/\/ assets.giants.com\/uploads\/players\/2FE2D3BDF4FB443D949D1D39B69ADC03.gif], PlayerCollege:[Cal Poly]}} ...which when pasted into JSONLint returns valid. If anyone has any ideas, or if there's any additional information that I can provide, I'm all ears. Thanks! Charlie -- Charlie Grieferhttp://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: getJSON callback not firing?
Well...I'm a self-taught, learn-it-as-I-go, programmer. So there are a lot of fundamentals that I probably don't know that would be in the programming 101 class. I was just speaking from the limited experience of changing a post which was being used to just get some info from a query, to a get method to see if the results were the same. They were, so I just commented on the face that the performance of that query with either method was the same. I'll have to study up on get vs post so I can consider myself at least a well-versed, basic programmer. -Original Message- From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of MorningZ Sent: Friday, September 25, 2009 11:19 PM To: jQuery (English) Subject: [jQuery] Re: getJSON callback not firing? the method as post, occasionally venturing to use get when just retrieving data, just to see what might happen.nothing different. Wow, really? knowing the difference between GET an POST are pretty fundamental things to know as a programmer http://www.google.com/search?q=get+vs+post It's very important to understand the difference as browsers (mainly IE) have issues with GET in some cases, and all browsers handle caching differently between the two On Sep 25, 6:28 pm, Rick Faircloth r...@whitestonemedia.com wrote: Hang in there, Charlie! My head was very bloody from banging it against the wall when I first started down the AJAX road. Now I'm finally getting some work done with it! I almost gave up several times. fwiw, I have always used the $.ajax method without any problems and typically specify the method as post, occasionally venturing to use get when just retrieving data, just to see what might happen.nothing different. (and actually, I recognized that censored expression, having been there! :o) Rick From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of Charlie Griefer Sent: Friday, September 25, 2009 2:06 PM To: jQuery (English) Subject: [jQuery] getJSON callback not firing? Hey all: I've read the docs and googled the heck out of this, but not seeing what the problem is. I'm trying to get some data from the server via the getJSON() method. I do see a response in firebug and I've validated the response data at JSONLint.com. However, the callback function simply will not fire. I've tried to simplify things as much as possible. The CFC returning the data is in the same directory as the calling page. The callback function, for now, should only alert a simple text string (which has evolved from hi to foo to a censored version below as the hours have passed). $(document).ready(function() { $('a.players').click(function() { $.getJSON( 'data.cfc?method=getPlayerByIDreturnformat=JSONqueryformat=columnplayerID =' + this.id, function(data) { alert('i %!%##%* hate you'); }); return false; }); }); Here's the response I receive: {ROWCOUNT:1,COLUMNS:[PLAYERID,PLAYERNAME,PLAYERNUMBER,PLAYERPOSIT ION,PLAYERIMG,PLAYERCOLLEGE],DATA:{PlayerID:[1],PlayerName:[Bard en, Ramses],PlayerNumber:[13],PlayerPosition:[WR],PlayerImg:[http:\/\/ assets.giants.com\/uploads\/players\/2FE2D3BDF4FB443D949D1D39B69ADC03.gif], PlayerCollege:[Cal Poly]}} ...which when pasted into JSONLint returns valid. If anyone has any ideas, or if there's any additional information that I can provide, I'm all ears. Thanks! Charlie -- Charlie Grieferhttp://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: getJSON Callback not firing
Never mind, worked it out in the end. On 9 May, 13:45, Tane Piper [EMAIL PROTECTED] wrote: Hey folks, I'm trying to work on some cross-site stuff, and I'm using JSON between the domains to transfer the data. In my below code, the code fires the .getJSON, and I can see the JSON in my firebug scripts tag, but the callback is not getting fired: LoadContent = $.klass({ initialize: function(options){ $loadingarea = this.element; console.log($loadingarea) $.getJSON(options.url,{q:'nfp/front'}, function(data){ console.log(data); }); } }); $(document).ready(function(){ $('#loading-area-container').attach(LoadContent, {url: 'http://nfp.dev.lightershade.com/?jsoncallback=?'}); }); At the moment, here is the data I am trying to load: ({nid:1,title:Test Entry,type:story},{nid:2,title:Test 2,type:story}) It was contained in square brackets before like [{...}], but I changed it to () based on previous entries on the group, however it still will not go into the callback function. Does anyone have any idea what's going wrong here?? Thanks Tane Piperhttp://digitalspaghetti.me.uk