sorry for typing mistake, I am intended to represent the concept of
using callback.
and I think keeping default variable is not bad as we cant tell the
default value not to be changed in the next generation of prototype
js.
heeae
On Dec 22, 1:25 pm, joe t. thooke...@gmail.com wrote:
function show(){alert(get_data_default());}
This line will fail when you call show() because you're not passing a
function to fill the callback variable inside get_data_default().
Also, method:post and asynchronous:true are the defaults for those
options. You don't need to specify them if you plan to keep those
settings.
-joe t.
On Dec 20, 10:47 pm, heeae csche...@gmail.com wrote:
I will using this approach
function get_data_default(callback){
new Ajax.Request('/adress',
{
method:'post',
asynchronous:true,
onSuccess: function(data){ callback(data.responseText.evalJSON
(true); },
onFailure: function(){ alert('Something went wrong...') }
});
}
function show(){alert(get_data_default());}
var data = null;
function processData(obj){ data = obj; alert(data.abc); }
if(data == null){
get_data_default(processData);
}else{
alert(data.abc);
}
On Dec 20, 7:35 pm, kangur91 kangu...@gmail.com wrote:
My code:
function get_data_default() {
new Ajax.Request('/adress',
{
method:'post',
asynchronous:true,
onSuccess: function(data){ return data.responseText.evalJSON
(true); },
onFailure: function(){ alert('Something went wrong...') }
});}
}
function show(){alert(get_data_default());}
I want to function get_data_default return data recived from OnSucces
function. How do that?
--
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-scriptacul...@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.