tags:

views:

66

answers:

2

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
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
How do i get an integer value. my parseInt(result) is not invoked and no error
Greens
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