In the web page I have the following ajax call:
Code: Select all
$.ajax({type: "POST", url: 'TIMESET', async: false, data: t, timeout: 4000,
success: function(data){
alert("OK" + data);
},
error: function () {
alert("Error updating time");
}
});
Code: Select all
oldPostHandler = SetNewPostHandler( doPost ); // Redirect Web page POST handler
Code: Select all
int doPost( int sock, char *fname, char *pData, char *rxBuffer ){
time_t RawTime;
if (strcmp("/TIMESET",fname) == 0){
RawTime = atol(pData); // time from browser in seconds
set_time( RawTime ); // Update the time
sprintf(rxBuffer, "HTTP/1.1 200 OK\r\n[data]");
return 0;
}
else
{
sprintf(rxBuffer, "HTTP/1.1 400");
return 1;
}
}
How can I get the code to send back either OK or error, and can i send back data as well.
I don't think i have to put the HTTP code in the rxBuffer.
I would have thought that the return code would be the correct signal but I have tried 0 and 1 as return codes and both give 'error'.
any help would be appreciated.
Thanks
Lachlan