I want to send 2 values to php using ajax. When I use one variable, it works fine, but when I use 2 variables, the query no longer works in the php file.
$.ajax({
url:'page.php?suplier_id='+suplierNameMain+'&quality_id='+qualityNameMain,
method:'GET', success:function(data) {
});
If I use only supplier_id, everything works great.
P.S qualityNameMain shows correct value in console.log()
I’m sure it’s not related, but there is no reason to build your own query string. Use the
dataproperty instead, which as Barmar points out will properly URL encode your parameters:Note that
methodfrom your example isn’t valid for jQuery (there is atypesetting to switch betweenGETandPOST), butGETis the default so you might as well exclude it altogether.