Could you please provide me a simple example for assembling the request and sending to the server using the RecordSet? If someone knows how,please post it here.
Also how do I handle the form post-back, any ideas?
Thanks!!
Could you please provide me a simple example for assembling the request and sending to the server using the RecordSet? If someone knows how,please post it here.
Also how do I handle the form post-back, any ideas?
Thanks!!
There are two fairly independant parts to this. I generally use something along these lines.
First you want to get all the data from the datatable:
function getAllData(dataTable) {
var aData = [];
var aRecs = dataTable.getRecordSet().getRecords();
for (i=0; i < aRecs.length; i++) {
aData.push(aRecs[i].getData());
}
return(aData)
}
Next you want to post it. Since this is a complex data structure (array of rows of data), it's easiest to just send it encoded as JSON. You can then decode this in save.cgi:
function postDataToServer(aRows) {
YAHOO.util.Connect.asyncRequest(
'POST', 'cgi-bin/save.cgi', {
success: function (o) {
// Examine output of save.cgi in o.responseText
},
failure: function (o) {
// Error text in in o.responseText
}
}, "data="+encodeURIComponent(YAHOO.lang.JSON.stringify(aData))
);
};
The script save.cgi will need to check the value passed the the "data" parameter.