How to call a specific function in a PHP script via Ajax?

前端 未结 5 727
忘了有多久
忘了有多久 2021-02-06 15:53

Lets say I have a file called functions.php, and it has two separate functions inside:

One would get the time

And the other would get the date

How will I

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-06 16:16

    You don't specify in jQuery what function to execute in PHP. What you do is request a document, possibly with a query string, and read the results. Your functions.php script is responsible for executing whatever is requested.

    So, you might from jQuery request functions.php?fn=time in one place and functions.php?fn=date in another. Then, in functions.php, you would examine the query string and execute the appropriate function for what was requested, returning the results to jQuery.

提交回复
热议问题