timgerrlists
2007-Sep-24 21:43 UTC
Create an AJAX function with prototype. Cant return data
Hey all I am trying to create a Prototype Ajax functino that will
return the data out of the fuinction. Here is my code
[code]
function SendData(urlString,url)
{
var opt = {
// Use POST
method: ''post'',
// Send this lovely data
//postBody: ''p1=firsttime'',
postBody: urlString,
// Handle successful response
onSuccess: function(t) {
// Sending the responcd to be parsed and entered in the correct
places
alert("From withing the function ** " + t.responseText +
"
**");
return(t.responseText); // <---- Trying to return data
},
// Handle 404
on404: function(t) {
alert(''Error 404: location "'' + t.statusText
+ ''" was not
found.'');
},
// Handle other errors
onFailure: function(t) {
alert(''Error '' + t.status + '' --
'' + t.statusText);
}
}
return returnData; // <-------Trying to return data
new Ajax.Request(url, opt);
}
</script>
<script type="text/javascript">
function doME()
{
var test =
SendData(''lala'',''http://miys02ae211935l/learn/
dhtmlwindow/showme.php'');
alert(test);
}
[/code]
in the doMe function I would like to return the var test from the
SendData Function. Not sure why this is not working.
Thanks,
timgerr
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---