I wanna kn is it possible to pass query string along with URL when we call on Jquery Ajax;
Example :
$.ajax({
type: "POST",
url: "index.php?task=addNewInfo",
data: $('#regForm').serialize(),
dataType: "json",
.....
});
So does the query string from the param task works fine? or we need to do it the other way? Thank you.
Send the task in the data parameter
data:"task=addNewInfo&" + $('#regForm').serialize()
This is for using POST method. If you want to use GET method then Arun's solution will work fine.
I think the following will work fine
url : "index.php?task=addNewInfo&" + $('#regForm').serialize()
But why do you want to pass the form values as query params? The post request will pass the values as request params anyway. These params will be sent via the request body which is why you are using POST
request type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With