weixin_33674437 2018-02-13 03:51 采纳率: 0%
浏览 39

AJAX和JSP,$ getJSON

So im really having difficulties in understanding the parameters of $.getJSON(), Im currently in my OJT, and there is a AJAX request parameter that I cant figure out.

$.getJSON(jspGetElems, {elem: $(this).val()}).done(function(result){
        //console.log('result',result);
    });

what does the " {elem: $(this).val()} " actually mean?

  • 写回答

1条回答 默认 最新

  • weixin_33733810 2018-02-13 04:35
    关注

    jQuery.getJSON() has 3 parameter url,data and success. here, in your question elem: $(this).val() is data. You can pass multiple data to server like

    {
      "one": "Singular sensation",
      "two": "Beady little eyes",
      "three": "Little birds pitch by my doorstep"
    }
    

    Try example.

    $.getJSON( "https://jsonplaceholder.typicode.com/posts",{ userId: 1 } ) 
                .done(function(result){ console.log('result',result); });
    
    评论

报告相同问题?