The following editor will bring you an article on how to obtain the return parameters of the php page through ajax and assign values to the controls. The editor thinks it's pretty good, so now I'll share the source code of ajax with you, and also give you a reference. If you are interested in ajax, please follow the editor to have a look
js page
##
$.ajax({ type : "get", url : "", //跳转页面 data :"m=content&c=favorite&a=del_favorite&shoucangId="+_id,//传递的参数 datatype : "html", async:'false', success : function(data) //返回值 { if(data !=null) { var str= new Array(); //定义一数组 str=data.split(","); //字符分割 var title=str[0]; var url=str[1]; var type=str[2]; var id=str[3]; $("#title").val(title); // jQuery控件赋值 $("#url").val(url); $("#shoucnag_id").val(id); if(type=='钢琴谱') $("input[name='radio'][value='钢琴谱']").attr("checked",true); else if(type=='钢琴曲') $("input[name='radio'][value='钢琴曲']").attr("checked",true); } else { alert('失败!');return false; } } });
PHP page
$shoucangId=$_GET['shoucangId'];//获取传递的参数 $where="ID='$shoucangId'"; $signalInfo=array(); $signalInfo=$this->db->get_one($where,'*','',''); //此处借用PHPCMS二次开发的例子,select数据库中的一个数据集,存于数组$signalInfo中 if($signalInfo!=null) { $str=$signalInfo['title'].",".$signalInfo['url'].",".$signalInfo['type'].",".$signalInfo['id'];//将要返回的数组用逗号拼接成字符串返回 exit($str); } else { exit('0'); }
Related recommendations:
A brief analysis of the problem of json data transmitted from Ajax background success
Ajax example code for submitting Form form and file upload
Ajax implements partial refresh login interface with verification code
The above is the detailed content of Ajax gets the return parameters of the php page and the method of assigning values to the control. For more information, please follow other related articles on the PHP Chinese website!