从php页面调用php函数的ajax [英] ajax calling of php function from a php page
本文介绍了从php页面调用php函数的ajax的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的jQuery代码:
This is my jQuery code:
$.ajax({
type: "POST",
url: "process.php",
success: function(msg){
}
});
在process.php页面中,我有多个功能.一种功能是sendmail().
In process.php page I have more than one function. One function is sendmail().
如何通过ajax调用此函数?我写的代码为:
url: "process.php/sendmail",
但什么也没发生.
How can I call this function through ajax? I wrote the code as:
url: "process.php/sendmail",
but nothing happens.
推荐答案
通过Ajax
调用将data
传递给process.php
.
$.ajax({
type: "POST",
url: "process.php",
data: {method: 'one'},
success: function(msg){
}
});
在php页面中,
if(isset($_POST["method"])) {
$method = $_POST["method"];
if($method=="one") {
//call methods/functions here
}
}
这篇关于从php页面调用php函数的ajax的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文