0

In my spring project I am sending request through Ajax call like this:

function doAjaxPost(currentPage) {

    var appName = document.searchForm.txtZipFile.value;  
    var e = document.getElementById("selectStatus");
    var appStatus = e.options[e.selectedIndex].text;        


    $.ajax({  
     type : "GET",   
     url : "http://localhost:8080/ preListOnSearch.do",   
      data : "currentPage=" + currentPage + "&appName=" + appName + "&appStatus="  
       + appStatus, 
       cache: false,

     success : function(response) {           
      alert(response);   
     },  

     error : function(e) {  
      alert('Error: ' + e);   
     } 

    }); 
   }  

And in my controller I wrote method like:

@RequestMapping(value = "/preListOnSearch", method=RequestMethod.GET)
public String preTestDataolx(@PathVariable("siteId") String siteId,                  @PathVariable(value = "currentPage") String currentPage,
         @RequestParam(value = "appStatus") String appStatus) {
    System.out.println(appStatus);
    return "/preTestData";  
}

But this give me error. When I remove RequestParams from method definition it works fine. So I just want to know that how can I access ajax call parameter in controller.

1
  • it works fine no error is there Commented Jun 24, 2014 at 9:57

1 Answer 1

1

Try setting the data as a JS object:

$.ajax({  
   type : "GET",   
   url : "http://localhost:8080/ preListOnSearch.do",   
   data : {currentPage: currentPage, appName: appName, appStatus: appStatus},
   cache: false,
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.