0

Ajax send multiple data

How can I send multiple GET data via ajax to a php file without jQuery?

22nd Sep 2020, 8:08 AM
Mohammad Sajjad
Mohammad Sajjad - avatar
1 Antwort
0
GET cannot have a body. It can only send data as query params. You can send this data by appending them to the url like this. http://mysite.com?asker=Mostafa&q=Is%20this%20valid Using ES6 fetch API the code will be like this. fetch('http://mysite.com?asker=Mostafa&q=Is%20this%20valid') .then(resp => resp.json()) .then(data => cb(data)); This code assumes that the server responds with valid json and you have a cb function in your js to work on the data. It will send a GET request to http://mysite.com with the following data $_GET [ 'asker' => 'Mostafa', 'q' => 'Is this valid', ]
22nd Sep 2020, 9:17 AM
Ore
Ore - avatar