In the following code what is function(payload) doing??Actually i put an alert in function(payload){} i so not see the alert
EDIT
Also i see that there is a repose from the server but why is that i do not see an alert here
$("form#form").submit(function(){
$.post(url,
{
time: timestamp,
action: "postmsg",
message: $("#msg").val()
},
function(payload) {
alert('1');
$("#msg").val(""); // clean out contents of input field.
},
'json'
);
Even with weird indentation I’m able to understand what’s going on with my crazy JavaScript skills.
Your
function(payload)is a callback to the$.postrequest. The callback will be called once the AJAX$.postrequest is done.You probably don’t see it run because
urlis returning a bad status code. The$.postcallback will only run if theurlis accessible with a correct status code.For debugging try accessing
urljust from your browser, and see what happens.