简体   繁体   中英

Is there a way to have javascript to execute a php command?

I am trying to find a way to may a onclick javascript function execute a mailer script that I have setup on the same page. Is this possible?

<input type="radio" name="power" value="Diesel Powered" onclick="executeMailer()">

您正在寻找AJAX

This is only possible using Ajax or similar. Google for it, there are enough tutorials and howtos around.

No, your javascript has make a request to the server. The server can then execute the php command.

You need to do a web request from your javascript code.

For instance, if the php code you want to run is located at http://www.yo.com/target.php , you need to make an http request to this page from your javascript code, grab the response and do what you need to do with it.

It is called AJAX.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM