Link to home
Start Free TrialLog in
Avatar of Rose_Taylor
Rose_TaylorFlag for United States of America

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.toString());
          
        } catch (Exception e) {
          log.error(e);
                              }
        return jo.toString();
        }

Output format:

    {"col1":"col1","col2":"col2"}

I'm not getting data to jQuery success.
Please correct me, whats wrong here ?
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rose_Taylor

ASKER

actually here search.jsp is the original file.but i have created popup window.so i have one more form in the same jsp file.
good