在ajax中调用PHP函数 [英] Call PHP function in ajax

查看:152
本文介绍了在ajax中调用PHP函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的编码

Hi this is my coding

function jsfun(var1_name)
{
document.getElementById('txth1').value=var1_name;

$.ajax(
{
 type: "POST",
 data: "v="+var1_name,
 success: function(){
   var y="<?php pfun();?>";// call to PHP function 
 	alert(y);
 }
});
return false;
}





<?php
function pfun(){
	
	echo($a);
}
?>


我需要的是我必须将变量var1_name传递给tha函数PHP pfun.
这个怎么做?请帮助.


What i need is i have to pass the variable var1_name to tha PHP function pfun.
How to do this? Pls help.

推荐答案

.ajax( { 类型:" , 数据:" + var1_name, 成功:功能(){ var y = " ; 调用PHP函数 警报(y); } }); 返回 ; }
.ajax( { type: "POST", data: "v="+var1_name, success: function(){ var y="<?php pfun();?>";// call to PHP function alert(y); } }); return false; }





<?php
function pfun(){
	
	echo(


a); } ?>


我需要的是我必须将变量var1_name传递给tha函数PHP pfun.
这个怎么做?请帮助.


What i need is i have to pass the variable var1_name to tha PHP function pfun.
How to do this? Pls help.


function jsfun(var1_name)
{
  document.getElementById('txth1').value=var1_name;


这篇关于在ajax中调用PHP函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆