FancyBox $.post success callback failed?
I have a fancy box with the follow code:
$("a#inline").fancybox({
'titleShow' : false,
'width' : 500,
'height' : 500
});
And a $.post calling when submit button in fancybox clicked.
$("#submitbtn").live('click',function(){
var timesch = $("#timesch").val();
var actsch = $("#actsch").val();
var postdata ="timesch=" + timesch + "&actsch=" + actsch;
//$.fancybox.showActivity();
$.post("insertsch.php",postdata,function(data){
alert(data);
});
});
The matter is the alert(data); doesn't pop back what it suppose to in the succe开发者_高级运维ss call. I've tested the content in php insertsch.php it work normally but not when it passing back to the success....
in insertsch.php code:
<?php
//bla bla insert into database then echo this success
echo "success";
?>
**Note alert(data) is simply just to post back echo "success" in the insertsch.php to test the callback working or not and it doesn't somehow.
Found the problem cause I didn't return false after ajax posting...
Your post data needs to be in an object literal. Try this:
var postdata = {timesch : timesch, actsch : actsch};
精彩评论