i have a javascript file that contains an array myfile.js. i don't have the right to change anything in this js file .
so i added a php file that i call through a web service , i call this php file with POST request with an email as a parameter .
so what i am trying to do is to get the array in myfile.js and pass it to the php file so that i can check if the email does not exists in that array then i can return as a json response true or false.
after many research i found a way to pass the js array to the php file here is my code :
<script type='text/javascript' src='js/content/myfile.js'></script>
<script>
myarray = myfile.myarray;// this works ,i can get the array
var hashes = window.location.href.valueOf().split('?');
// alert(hashes[1]);
try {
hashes = hashes[1].split('&');
// alert(hashes[1]);
hashes = hashes[1].split('=');
}
catch ( e){
alert(e.message);
}
if (hashes[1] == 0)
{
hashes[1]++;
//alert(hashes);
top.location.href='http://direct.chancepure.com/voyance/PpSpamtram.php?array='+myarray+'&count='+hashes[1];
}
</script>
<?php
$phpArray=$_GET["array"];
/* then i check for the email existance then return a response ......*/
what this code does is add the myarray from the js file to the url using GET : redirect to the same url but adding the array to the parameters , NOTE : i added a count parameter so that i avoid infinit loop.
this method works fine on a browser because the javascript code and the redirection works , but when i call it from Postman or other tools it does not . need your help guys.