Maison > Article > développement back-end > PHP中回调函数的写法求解解决办法
PHP中回调函数的写法求解
PHP中回调JQuery $.post中的函数,传递1个参数我就知道,但传递多个参数该如何写?
如以下例子:$.post("/home/getcode",function(cl7,cl8){var cl9=cl7.SecCode;var cla=cl7.KCode;var clb=camelcrypto(cl9,cla);$.post("/home/vote",{id:cl6,selOpts:cl4,questName:cl5,chkCode:$("#chkcode").val(),secCode:clb,num1:Math.random()},function(clc,cld){$("#btn_vote").show();var cle=clc.RCode;$("#vote_tips").text("");if(cle==-1000){$("#chkCodeMsg").text(clc.Msg);$("#chkCodeDialog").dialog("open");$("#chkCodeDialog a").click()}else{alert(clc.Msg);if(clc.Success){document.location=document.location}}})})};cl2.preventDefault()});$("#btn_votecode").click(function(){$("#btn_vote").click()})});function showVoteBar(){$(".vcount").show();$(".votebar :hidden").each(function(cl0){var cl1=$(this).val();$(this).parent().animate({"width":cl1+"px"},1000)})}
PHP中该如何返回调用
------解决方案--------------------
function(cl7,cl8)
改为
function(d) {
c17 = d.c17;
c18 = d.c18;
php:
echo json_encode(array('c17' => 123, 'c18' => 456));
jq 不可能预知你要怎么用它,所以才用了统一格式来处理
就所谓:以不变应万变