Is there an example for the $.ajax() that returns values from a webservice or should I use $.ajaxSetup() ?
+1
A:
The jQuery ajax docs have a whole tab of examples.
Particularly, you can look at the success callback in the options tab to see the appropriate syntax for getting the data that's returned.
Gabriel Hurley
2009-09-10 21:53:36
A:
Gabriel Hurley has given the right answer, I just want to elaborate a bit. I like to use the ajax function, rather than get or post as I find it more readable and you can react to the different results of the ajax call.
$.ajax({
type: "GET",
dataType: "html"
url: "services/addUser",
data: "{name:'Jo', email:'[email protected]'}",
success: function(result){
//It worked!
},
error: function(err) {
//The ajax call didn't work
alert("It didn't work: " + err);
}
});
daddywoodland
2009-09-10 23:02:06
How do i get an integer value. my parseInt(result) is not invoked and no error
Greens
2009-09-11 15:22:54
If it's not getting called you need to check where the script is failing so debug it with firebug/visual studio. If you wanna give some more detail I'll have a look.
daddywoodland
2009-09-11 20:10:28