Doubt about ajax (javascript)

-2

With a doubt, you can send from index to api (using ajax) more than one value ?. I am accustomed to using the code like that. But I do not know how to send the value of 2 different inputs.

<script>
$.ajax({
    url: 'api.php?line=' + value,
    type: 'GET',
</script>
    
asked by anonymous 14.08.2018 / 22:54

2 answers

0

Use & to separate parameters:

$.ajax({
    url: 'api.php?line=' + value + '&other=' + outro,
    type: 'GET'
});

If there are many values or long values, use POST instead of GET .

    
14.08.2018 / 23:06
0

I would advise you to search on query strings is really your limitation and it has nothing to do with the request via Ajax.

See an article on query string in Wikipedia link

Do not go into details about constructing the URL to indicate that the parameters in the URL are separated by the character "&" according to the formula: Parameter_name_1 = Parameter_value_1 & Parameter_name_2 = Parameter_value_2 & Parameter_name_3 = Parameter_value_3 ...

Using your example I'll append column parameter

<script>
$.ajax({
   url: 'api.php?line=' + value +'&coluna=' + value2,
   type: 'GET',
</script>
    
14.08.2018 / 23:07