[PHP/JavaScript]: Call PHP file through JavaScript code with argument

后端 未结 4 926
不思量自难忘°
不思量自难忘° 2021-01-28 14:44

I want to call a PHP file but want to pass an argument to the PHP file. Not getting the correct approach, I am attempting to write a cookie and read that cookie when the PHP fil

4条回答
  •  太阳男子
    2021-01-28 15:14

    I'm not sure what in your code (running on the client's PC) you expect to cause the php script (running on the server) to run. You'll need to invoke the php by making some kind of http request (like get http://yoururl/recheckcookie.php). With at HTTP request, the javascript code on the client to queries the webserver for the output of your recheckcookie.php script. This script can then recheck the cookie, and return some/no output.

    Look up XMLHttpRequest or preferably the corresponding JQuery to see how to perform the HTTP request.

提交回复
热议问题