AJAX 和 JSP , $getJSON
AJAX and JSP , $getJSON
所以我真的很难理解 $.getJSON() 的参数,我目前在我的 OJT 中,并且有一个 AJAX 请求参数我无法理解。
$.getJSON(jspGetElems, {elem: $(this).val()}).done(function(result){
//console.log('result',result);
});
“{elem: $(this).val()}”到底是什么意思?
jQuery.getJSON() 有 3 个参数 url、数据和成功。在这里,在你的问题中 elem: $(this).val() 是数据。您可以将多个数据传递给服务器,如
{
"one": "Singular sensation",
"two": "Beady little eyes",
"three": "Little birds pitch by my doorstep"
}
尝试示例。
$.getJSON( "https://jsonplaceholder.typicode.com/posts",{ userId: 1 } )
.done(function(result){ console.log('result',result); });
所以我真的很难理解 $.getJSON() 的参数,我目前在我的 OJT 中,并且有一个 AJAX 请求参数我无法理解。
$.getJSON(jspGetElems, {elem: $(this).val()}).done(function(result){
//console.log('result',result);
});
“{elem: $(this).val()}”到底是什么意思?
jQuery.getJSON() 有 3 个参数 url、数据和成功。在这里,在你的问题中 elem: $(this).val() 是数据。您可以将多个数据传递给服务器,如
{
"one": "Singular sensation",
"two": "Beady little eyes",
"three": "Little birds pitch by my doorstep"
}
尝试示例。
$.getJSON( "https://jsonplaceholder.typicode.com/posts",{ userId: 1 } )
.done(function(result){ console.log('result',result); });