Following is the code I use for an ajax call. While executing this it gives me an error xml parsing error syntax error line number 1 column 1 in fiebug. I viewed some questions stating the same problem and they suggested that there was some syntactical problem. I checked again but couldn't find out the real culprit. Please tell me what I am doing wrong.
$.ajax({type: "GET",
cache: false,
url: 'url',
data : 'param1='+ param1val+ '¶m2='+param1val,
dataType: 'json',
success: function(Obj){
if(Some Condition){
//Some Code
}else{
//else code
}
},
});
Here goes some controller code.
@RequestMapping(value = "url", method = RequestMethod.GET)
public @ResponseBody SomeObject url(@RequestParam(value="param1val") String abc ,@RequestParam(value="param2val") String xyz)
{ //some code}
Edit I added some debugging code to JS and the controller code as well. To my surprise, control executes successful first es (in JS) and then goes into controller. Is it supposed to happen like this?
Following is the code I use for an ajax call. While executing this it gives me an error xml parsing error syntax error line number 1 column 1 in fiebug. I viewed some questions stating the same problem and they suggested that there was some syntactical problem. I checked again but couldn't find out the real culprit. Please tell me what I am doing wrong.
$.ajax({type: "GET",
cache: false,
url: 'url',
data : 'param1='+ param1val+ '¶m2='+param1val,
dataType: 'json',
success: function(Obj){
if(Some Condition){
//Some Code
}else{
//else code
}
},
});
Here goes some controller code.
@RequestMapping(value = "url", method = RequestMethod.GET)
public @ResponseBody SomeObject url(@RequestParam(value="param1val") String abc ,@RequestParam(value="param2val") String xyz)
{ //some code}
Edit I added some debugging code to JS and the controller code as well. To my surprise, control executes successful first es (in JS) and then goes into controller. Is it supposed to happen like this?
Firefox shows this error if the response type is not set correctly. It tries to parse the response as XML. To fix it, set the response type for what you are sending back to the client, for example for JSON with Spring:
@RequestMapping(value = "url",
method = RequestMethod.GET,
produces = "application/json")