由网友(霸气十足小伙)分享简介:可以说我有一个名为functions.php文件,它里面有两个单独的函数:Lets say I have a file called functions.php, and it has two separate functions inside:一会获取时间和其他会得到的日期我将如何,使用JQuery AJAX...
可以说我有一个名为functions.php文件,它里面有两个单独的函数:
Lets say I have a file called functions.php, and it has two separate functions inside:
一会获取时间
和其他会得到的日期
我将如何,使用JQuery AJAX检索,检索日期功能的数据。我如何在JQuery的code服务器上的哪些功能来接指定。
How will I, using JQuery AJAX retrieve data from the function that retrieves the date. How do I specify in the JQuery code which function on the server to pick.
我希望我做的感觉。谢谢你。
I hope I am making sense. Thanks.
推荐答案
您可以包括Ajax请求数据的选择。例如:
You could include a selector in the ajax request data. For example:
$.ajax({
url: "functions.php",
data: "function=time", // or function=date if you want date
...
});
然后在你的PHP code,一个简单的if语句将其中一个检查输出。
Then in your PHP code, a simple if-statement will check which one to output.
if(isset($_GET['function'])) {
if($_GET['function'] == 'time') {
// do time stuff
} elseif($_GET['function'] == 'date') {
// do date stuff
}
}
相关推荐
最新文章