Hey guys this is pretty simple – I ran across a cool MVC example at Adam Wulf’s site and I’m trying to get a grip with how all the different pieces interact… Within the model.js he has two different ways of using the *data : * setting. Can someone please explain the differences between the two of them, and maybe an example of a different method? Code:
$.ajax({
url: 'ajax.php',
data : { load : true },
type: 'GET',
dataType: 'json',
timeout: 1000,
error: function(){
that.notifyLoadFail();
},
success: function(data){
loadResponse(data);
that.notifyLoadFinish();
}
});
Vs this example:
$.ajax({
url: 'ajax.php',
data : { load : true, id : id },
type: 'GET',
dataType: 'json',
timeout: 1000,
error: function(){
that.notifyLoadFail();
},
success: function(data){
loadResponse(data);
that.notifyLoadFinish();
}
});
It’s simply an anonymous object used to pass values to the server. In the first example, it contains a single value, “load”:
In the 2nd, it has two values:
…”load” and “id”. Take the 2nd example: the server will receive two parameters for the request. In PHP for example, you’d retrieve them with:
Make sense?
Cheers