So, you’re working in JavaScript and you need to pass content to a php page. On the JavaScript side, you do this: –

var formData=new FormData();
formData.append('myString', myString);

var url="./accessMyString.php";

xmlhttp=new XMLHttpRequest();
xmlhttp.open("POST", url, true);
xmlhttp.send(formData);

This will store the string (or anything else you need to pass) into ‘myString’ in the FormData and will trigger “./accessMyString.php” passing the data as a POST.

In “accessMyString.php”, you’ll read content from the POST using the usual: –

$myString = $_POST['myString'];

 

 

 

Advertisements