Skip to content Skip to sidebar Skip to footer

Passing Url Variable With & From Js To Php Result In "&" Omission

It is a bit difficult to find the proper title for this question for me, so maybe this example will clarify my issue. I am making an ajax request to pass some variables from a JS t

Solution 1:

Here's how to send it as POST request:

var php_url = '/shire/php/export_wfs.php';
var formData = new FormData();
formData.append('wfs_url', url);
formData.append('format', format_list[0]);
xhr.open('POST', php_url);
xhr.onreadystatechange = function () {
    if (xhr.readyState===4 && xhr.status===200) {
        alert('Server reply: ' + xhr.responseText);
    }
}
xhr.send(formData);

Solution 2:

try including this function (base64_encode):

var php_url = window.location.protocol + "//" + window.location.hostname + '/shire/php/export_wfs.php?wfs_url=' + base64_encode(url) + 'format=' + base64_encode(format_list[0]);

and on the server side:

$wfs_url = base64_decode($_GET['wfs_url']);
$format = base64_decode($_GET['format']);

Post a Comment for "Passing Url Variable With & From Js To Php Result In "&" Omission"