[jQuery] Callback from the $.post function is not being invoked
I'm new to jQuery and it has worked great for me...
except I seem to be having a problem with the $.post function.
The response comes back but the callback function is not invoked.
Here is the loop that I'm using to set the onChange event handler:
datafields = new Array( "#field1", "#field2", "#field3" ) ;
function edit_event_handlers( ) {
for ( var target in datafields ) {
$(datafields[target]).change( function(dft) {
return function() {
$(dft).css('background-color','orange') ;
var params = { fieldname: dft.replace("#",""),
fieldval: $(dft).val() }
$.post("/index.php/Workflow_server/updatefield/",
params,
function(){ alert("Data returned") ; }, "xml"
) ;
} ;
}(datafields[target]) ) ;
} ;
}
Using firebug I see the params are sent to the server process and the
xml data is returned:
(it just wraps $_POST in <test> tags)
<test>array(2) {
["fieldname"]=> string(7) "#field1"
["fieldval"]=> string(6) "345345"
}
</test>
... but the alert in the function never appears.
I also tried this line for the function parameter of the $.post call
without success:
function() { return function(rdata){ alert("Data returned: " +
rdata) } }
What am I missing here?
Thanks,
Eric