Saving Data from jQuery/EXT JS
jQuery.ajax({
url: 'page',
cache: false,
type: "post",
data: ({id: 1, idUser: 000}),
dataType: "html",
async: true,
success: function(data){
alert(date);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus);
}
});
It really depends on your server side system/frameworks etc. For example, if you were sending values to a WCF Web Service, you could configure said web service to expect whatever you fancy sending.
However, saving as URL POST params will remove requirement to decode values on the server side.
IE: If you save as JSON, you'll have to decode that JSON on the server side before you can use the values.
Here's a EXT JS:
Ext.Ajax.request({
loadMask: true,
url: 'myfile.php',
params: {id: "1"},
success: function(resp) {
// resp is the XmlHttpRequest object
var options = Ext.decode(resp.responseText).options;
Ext.each(options, function(op) {
alert(op.message);
}
}
});
精彩评论