PDA

View Full Version : Cannot get back data from the function



mo_sze
26 Mar 2011, 6:39 AM
Hi,

I would be grateful, if someone could help me.

I have a grid panel and I use a renderer.

This is the function for the renderer:

var global_data1 = new Object();

function GetNewspaperData(val,x,store){

var value = store.data.bundles_id;
Ext.Ajax.request({
url : '/extjs/GetData.php' ,
params : { action : 'getDataOrderNewspaper',
bundles_id: value},
method: 'POST',
success: function (resp){

var data = Ext.decode(resp.responseText);

global_data1.type_name = data.rows[0].type_name;
global_data1.publication_date = data.rows[0].publication_date;
global_data1.pages_amount = data.rows[0].pages_amount;
global_data1.newspaper_id = data.rows[0].newspaper_id;

},


});
return '<br>'+global_data1.type_name;

}

The problem is:

I can use alert(global_data1.type_name) , but i cannot get back as a return value from the function.
Undefined!!!

Thanks in advance
M.

mo_sze
26 Mar 2011, 6:42 AM
Hi,

I would be grateful, if someone could help me.

I have a grid panel and I use a renderer.

This is the function for the renderer:

var global_data1 = new Object();

function GetNewspaperData(val,x,store){

var value = store.data.bundles_id;
Ext.Ajax.request({
url : '/extjs/GetData.php' ,
params : { action : 'getDataOrderNewspaper',
bundles_id: value},
method: 'POST',
success: function (resp){

var data = Ext.decode(resp.responseText);

global_data1.type_name = data.rows[0].type_name;
global_data1.publication_date = data.rows[0].publication_date;
global_data1.pages_amount = data.rows[0].pages_amount;
global_data1.newspaper_id = data.rows[0].newspaper_id;

},


});
return '<br>'+global_data1.type_name;

}

The problem is:

I can use alert(global_data1.type_name) , but i cannot get back the data value as a return value from the function.
Undefined!!!

Thanks in advance
M.

conorarmstrong
26 Mar 2011, 6:45 AM
Ajax calls are asynchronous. The success handler will probably not be called prior to the execution of the statement following the Ext.Ajax.request call.

By the way, please include your code in proper code tags and try not to double post.