Hey guys,
I'm probably missing something simple. I'm requesting some data on the
back-end, and return a JSON string. The JSON string returned is exactly,
for example:
{"FName":"Mark","LName":"Holton","EmailAddress":"[EMAIL PROTECTED]
","Phone":4255555555}
I can return that JSON string and stuff it into any dom element with
Ajax.Updater without a problem. But I'd like to pass the data into the
function using Ajax.Request, then populate elements on the page, such as
$('txFirstName').value = jsonobj.FName; $('txLastName').value =
jsonobj.LName; etc.
There must be something wrong with how I'm trying to do this, however, as
I'm getting no response when using Ajax.Request, whereas I am able to
display the json in a DOM element when using Ajax.Updater. I'm wondering if
it's because Updater sees the text string okay, yet, in order for JS to
parse the incoming JS I have to do so with a header?:
<!-- this isn't working for me -->
function PopulateViaSID(SID) {
var passSID = encodeURIComponent(parseInt(SID));
var pars = 'FORM.passSID =' + passSID ;
new Ajax.Request()
var url =
'/SShow/Model/AjaxCalls/sshow_caller_populateRef.cfm';
new Ajax.Request(url, {
method: 'get',
onSuccess: function(transport, json) {
alert(json ? Object.inspect(json) : "no JSON object");
// no alert displays when I try this
}
});
<!-- this does return the string from the server and populate a DOM element
-->
new Ajax.Updater(resultDomElem,
'/Skillshow/Model/AjaxCalls/skillshow_caller_populateRef.cfm',
{
asynchronous:true,
parameters: pars,
onSuccess:function(){
$('txtRefNotes').value = 'hello'; //this worked
// $('txtRefFirstName').value = oUser.FName; //was
hoping I could do this, but it didn't work
Element.setOpacity(resultDomElem, 0.0);
Effect.Appear(resultDomElem,
{ duration: 0.5 });
new Effect.Highlight(resultDomElem, {startcolor:CEB195,
endcolor:F8F8D2});
}
}
);
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---