PDA

View Full Version : ajax response help



extjsuser2010
8 Feb 2010, 2:13 AM
well i have some piece of code here but am getting an undef output. i need to return an array from my JSP page through AJAX.

Ext.Ajax.request({

url:'backend4.jsp', // <-- replace with your url
method:'POST',
params:{ txt:Ext.get(textbox1).dom.value},
success:function(result,response) {
var JsonData=Ext.util.JSON.decode(result.responseText);
arr=JsonData.data.result;
alert(arr[1]);

},
failure:function(result,response) {
alert('ajax failed');
}

});

JSP PART:

String JsonStr="{\"success\":true,\"data\":{\"result\":\" "+result+"\"}}";
response.setContentType("text/html;charset=iso-8859-9");
response.getWriter().write(JsonStr);

i need to know whats wrong with this code. thanx in advance.

8 Feb 2010, 11:54 AM
What does your rendered JSON look like?