Rose_Taylor
asked on
Jquery Ajax retun issue
I'm not getting response as json type data from server.Please look into my code here...
jQuery( "#dialog-form" ).dialog({
autoOpen: false,
height: 500,
width: 750,
modal: true,
buttons :{
"Search" : function(){
jQuery.ajax({type : 'POST',
dataType : 'json',
url : '<s:url action="part" method="list" />',
success : handledata})
}
}
});
var handledata = function(data)
{
alert(data);
}
if dataType = 'json' am not getting any response, but if didn't mention anything dataType, getting html format of page.
public String list(){
JSONObject jo = new JSONObject();
try {
Iterator it = findList.iterator();
while(it.hasNext()){
SearchResult part = (SearchResult) it.next();
jo.put("col1",part.getcol1 ());
jo.put("col2",part.getcol2 ());
}
log.debug--------->:"+jo.t oString()) ;
} catch (Exception e) {
log.error(e);
}
return jo.toString();
}
Output format:
{"col1":"col1","col2":"col 2"}
I'm not getting data to jQuery success.
Please correct me, whats wrong here ?
jQuery( "#dialog-form" ).dialog({
autoOpen: false,
height: 500,
width: 750,
modal: true,
buttons :{
"Search" : function(){
jQuery.ajax({type : 'POST',
dataType : 'json',
url : '<s:url action="part" method="list" />',
success : handledata})
}
}
});
var handledata = function(data)
{
alert(data);
}
if dataType = 'json' am not getting any response, but if didn't mention anything dataType, getting html format of page.
public String list(){
JSONObject jo = new JSONObject();
try {
Iterator it = findList.iterator();
while(it.hasNext()){
SearchResult part = (SearchResult) it.next();
jo.put("col1",part.getcol1
jo.put("col2",part.getcol2
}
log.debug--------->:"+jo.t
} catch (Exception e) {
log.error(e);
}
return jo.toString();
}
Output format:
{"col1":"col1","col2":"col
I'm not getting data to jQuery success.
Please correct me, whats wrong here ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
good
ASKER