I'm having trouble trying to send data using ajax via GET method, here's my code, but it doesn't work
$("#selectTypeTour").change(function () {
let type = $(this).val();
$.ajax({
url: url,
type: 'GET',
data: {type: type},
success: function (res) {
console.log(res);
}
});
})
I tried by adding &type
after url
then it should work, so what's the problem here?Why is the data: {type: type}
not being received?
$("#selectTypeTour").change(function () {
let type = $(this).val();
$.ajax({
url: url + '&type=1',
type: 'GET',
data: {type: type},
success: function (res) {
console.log(res);
}
});
})
below is the processing code on my server
public function getLocation(){
if(isset($_GET['type'])){
echo $_GET['type'];
}
}
Here is the code in the .htaccess file
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?url=$1
I realized the problem was that if http:\\myurl?type=1
would not get the type value, if http:\\myurl&type=1
would get it, what is the problem?