How to send parameters with jquery $.get()

前端 未结 4 2064
粉色の甜心
粉色の甜心 2020-12-02 22:54

I\'m trying to do a jquery GET and i want to send a parameter.

here\'s my function:

$(function() {
    var availableProductNames;
    $.get(\"manag         


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-02 23:18

    This is what worked for me:

    $.get({
        method: 'GET',
        url: 'api.php',
        headers: {
            'Content-Type': 'application/json',
        },
        // query parameters go under "data" as an Object
        data: {
            client: 'mikescafe'
        }
    });
    

    will make a REST/AJAX call - > GET http://localhost:3000/api.php?client=mikescafe

    Good Luck.

提交回复
热议问题