What should I do if I want to pass the value of javascript to another php file in the same folder?
javascript php
The only way to do this is to send the value to the PHP file on the server.
Simply create a parameterized URL to a PHP file in JavaScript and open it in your browser, or
There is a way to send asynchronously from JavaScript without transition.
//Example data you want to send
var values = {
'val1': 'test value one',
'val2': 'test value two',
'val3': 'test value three'
};
// PHP path of interest
varphpUrl='./target.php';
// Create transmission parameters
varwork=[ ];
for(key in values) {work.push(key+"="+values[key]);}
var requests = work.join("&");
// If you want to transition without thinking,
location.href=phpUrl+'?'+requests;
// For asynchronous transmission asynchronously
varxhr = new XMLHttpRequest();
xhr.open('POST',phpUrl,false);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.send(requests);
xhr.abort();
© 2024 OneMinuteCode. All rights reserved.