js函数返回值有关问题
js函数返回值问题
用到了jquery 和 php 的一个ajax方法
就上段代码,返回值始终是123 ,不知道什么地方出了问题,我怀疑是变量的作用域不对
dt3.php 的代码也贴出来吧,
------解决方案--------------------
还真是,蛮复杂,js执行的顺序貌似不对
用到了jquery 和 php 的一个ajax方法
- JScript code
function imginfo() { var strtemp="123"; jq(document).ready(function(){ jq.post( 'dt3.php', { a:1 }, function (data) { var str=data.split("|"); for(var i=1; i<=str.length-1;i++){ var temparr=str[i-1].split("@"); if(i<str.length-1) { strtemp += "["+temparr[2]+","+temparr[0]+","+temparr[1]+"]"+","; } else strtemp += "["+temparr[2]+","+temparr[0]+","+temparr[1]+"]"; } } ); }); return strtemp;
就上段代码,返回值始终是123 ,不知道什么地方出了问题,我怀疑是变量的作用域不对
dt3.php 的代码也贴出来吧,
- PHP code
<?php require_once './source/class/class_core.php'; require_once './source/function/function_home.php'; $discuz = & discuz_core::instance(); $discuz->init(); //print_r($_G); //$str="1,1,1,1,1,1"; //DB::query("insert into dz_plugin1 (title,content,datetime,username,uid,filename) values ($str)"); $result=DB::query("select * from dz_plugin2"); $buff2=""; while($rs = mysql_fetch_array($result)){ $buff2.=$rs['title']."@".$rs['url']."@".$rs['filename']."|"; } echo $buff2; ?>
------解决方案--------------------
还真是,蛮复杂,js执行的顺序貌似不对