JSON response ... {"success" : "true", "message" : "good"}
Code ... function ajaxRequest2(){ var url = "/cgidev2p/r_chgpwd.pgm"; var pars = 'v_current=' + escape($F('v_current')) + '&v_new=' + escape($F('v_new')) + '&v_confirm=' + escape($F('v_confirm')) + '&sessionid=' + escape($F('sessionid')); //var submitObj = document.getElementById('goButton'); new Ajax.Request(url, { method: 'get', //contentType: 'application/json', parameters: pars, onSuccess: function(transport){ alert("Success"); var json = transport.responseJSON; alert(json.success); } , onError: function(transport){ alert("skipped"); } , onComplete: function(transport){ alert("Complete"); } }); } Alerts that I see are Success and Complete. The alert(json.success) does not fire. If I change the code to alert(json) the alert fires with "null". -----Original Message----- From: prototype-scriptaculous@googlegroups.com [mailto:prototype-scriptacul...@googlegroups.com] On Behalf Of Alex McAuley Sent: Saturday, October 31, 2009 5:20 AM To: prototype-scriptaculous@googlegroups.com Subject: [Proto-Scripty] Re: Ajax.Request with JSON response If its Json then the alert would be... alert(jsonObj.success); HTH Alex Mcauley http://www.thevacancymarket.com ----- Original Message ----- From: "mjhaston" <mjhas...@gmail.com> To: "Prototype & script.aculo.us" <prototype-scriptaculous@googlegroups.com> Sent: Friday, October 30, 2009 1:21 PM Subject: [Proto-Scripty] Re: Ajax.Request with JSON response > > The "success" alert fires off, but not the "feeling ok" alert. > > > > function ajaxRequest2(){ > var url = "/cgidev2p/r_chgpwd.pgm"; > var pars = 'v_current=' + escape($F('v_current')) + > '&v_new=' + escape($F('v_new')) + '&v_confirm=' + escape($F > ('v_confirm')) + '&sessionid=' + escape($F('sessionid')); > //var submitObj = document.getElementById('goButton'); > new Ajax.Request(url, { > method: 'get', > contentType: 'application/json', > parameters: pars, > > onSuccess: function(transport){ > alert("Success"); > var jsonObj = transport.responseJSON; > alert('feelingOk:' + jsonObj['success']); > }, > onComplete: function(transport){ > alert("Complete"); > } > }); > } > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---