[jQuery] Re: Using getJSON...not successful
Also i'd suggest using Firebug (http://www.getfirebug.com/), it's Console tab will tell you errors in the Ajax call as well On Jan 19, 10:29 am, "Rick Faircloth" <[EMAIL PROTECTED]> wrote: > Now, I've never used Ajax, so this is just a short in the dark > at the broad side of a barn. > > With that in mind, I was wondering if the "/mysite/myajax" part > shouldn't have an extension on the "myajax" part, as in "myajax.html" > or something? > > If not why not? Isn't that referring to a specific page on your site? > > Rick > > > -Original Message- > > From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of gms > > Sent: Friday, January 18, 2008 6:13 PM > > To: jQuery (English) > > Subject: [jQuery] Using getJSON...not successful > > > Hello, > > I am new to JQuery. I'm trying to get a JSON response back from my > > django view. However, I guess my data never gets loaded > > successfully. Does anybody know what I'm doing wrong? > > > > > $(document).ready(function(){ > > $("#first").click(function(){ > > $.getJSON("/mysite/myajax", function(data) { > > alert("Here"); > > }); > > }); > > }); > > > > > > > def myajax(request): > > a = Testimonial.objects.all()[:3] > > response_dict = {} > > response_dict.update({'a': a}) > > return HttpResponse(simplejson.dumps(response_dict), > > mimetype='application/javascript') > > > /// > > > Whenever I access this page and click on my div that contains the id > > 'first'...nothing happens. I should see an alert that says 'Here'. > > > Any Suggestions on what I'm doing wrong? > > > Thanks
[jQuery] Re: Using getJSON...not successful
Now, I've never used Ajax, so this is just a short in the dark at the broad side of a barn. With that in mind, I was wondering if the "/mysite/myajax" part shouldn't have an extension on the "myajax" part, as in "myajax.html" or something? If not why not? Isn't that referring to a specific page on your site? Rick > -Original Message- > From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of gms > Sent: Friday, January 18, 2008 6:13 PM > To: jQuery (English) > Subject: [jQuery] Using getJSON...not successful > > > Hello, > I am new to JQuery. I'm trying to get a JSON response back from my > django view. However, I guess my data never gets loaded > successfully. Does anybody know what I'm doing wrong? > > > $(document).ready(function(){ > $("#first").click(function(){ > $.getJSON("/mysite/myajax", function(data) { > alert("Here"); > }); > }); > }); > > > > def myajax(request): > a = Testimonial.objects.all()[:3] > response_dict = {} > response_dict.update({'a': a}) > return HttpResponse(simplejson.dumps(response_dict), > mimetype='application/javascript') > > /// > > Whenever I access this page and click on my div that contains the id > 'first'...nothing happens. I should see an alert that says 'Here'. > > Any Suggestions on what I'm doing wrong? > > Thanks
[jQuery] Re: Using getJSON...not successful
The problem with using the shortcut methods for new people is that it does not give you any error feedback. I would suggest that you use the $.ajax method till you get used to the process, it will allow you to set for errors. But in the mean time, put the below before you getJSON method: $("#msg").ajaxError(function(event, request, settings){ $(this).append("Error requesting page " + settings.url + ""); }); just create a div with the id of msg. This "should" print out what the error is. If not, then go with the $.ajax method. $.ajax({ url: URL, dataType : 'json', data : {}, success : function(data, textStatus){ }, error : function(x, txt, e){ alert(txt); } }); On 1/18/08, J Moore <[EMAIL PROTECTED]> wrote: > > > > to isolate the problem, make your script dump out something like: > {"a": "hello"} > > are you sure it's not a 404? is jquery being found? It could be lots > of things... > > if you haven't already, install firebug (and use firefox). It will > save you a lot of frustration. > > On Jan 18, 6:13 pm, gms <[EMAIL PROTECTED]> wrote: > > Hello, > > I am new to JQuery. I'm trying to get a JSON response back from my > > django view. However, I guess my data never gets loaded > > successfully. Does anybody know what I'm doing wrong? > > > > > > $(document).ready(function(){ > > $("#first").click(function(){ > > $.getJSON("/mysite/myajax", function(data) { > > alert("Here"); > > }); > > });}); > > > > > > > > > > def myajax(request): > > a = Testimonial.objects.all()[:3] > > response_dict = {} > > response_dict.update({'a': a}) > > return HttpResponse(simplejson.dumps(response_dict), > > mimetype='application/javascript') > > > > /// > > > > Whenever I access this page and click on my div that contains the id > > 'first'...nothing happens. I should see an alert that says 'Here'. > > > > Any Suggestions on what I'm doing wrong? > > > > Thanks > -- Benjamin Sterling http://www.KenzoMedia.com http://www.KenzoHosting.com http://www.benjaminsterling.com
[jQuery] Re: Using getJSON...not successful
to isolate the problem, make your script dump out something like: {"a": "hello"} are you sure it's not a 404? is jquery being found? It could be lots of things... if you haven't already, install firebug (and use firefox). It will save you a lot of frustration. On Jan 18, 6:13 pm, gms <[EMAIL PROTECTED]> wrote: > Hello, > I am new to JQuery. I'm trying to get a JSON response back from my > django view. However, I guess my data never gets loaded > successfully. Does anybody know what I'm doing wrong? > > > $(document).ready(function(){ > $("#first").click(function(){ > $.getJSON("/mysite/myajax", function(data) { > alert("Here"); > }); > });}); > > > > > def myajax(request): > a = Testimonial.objects.all()[:3] > response_dict = {} > response_dict.update({'a': a}) > return HttpResponse(simplejson.dumps(response_dict), > mimetype='application/javascript') > > /// > > Whenever I access this page and click on my div that contains the id > 'first'...nothing happens. I should see an alert that says 'Here'. > > Any Suggestions on what I'm doing wrong? > > Thanks