Home > Web Front-end > JS Tutorial > body text

jquery asynchronous loop acquisition function implementation code_jquery

WBOY
Release: 2016-05-16 18:19:19
Original
1071 people have browsed it

HTML code:

Copy code The code is as follows:


……
" class="address">

jquery code:

Copy code The code is as follows:

$(document).ready(function(){
$("#repTable span.address").each(function(){
var spanTemp = $(this);
$ .ajax({
type: "get",
url: "SceneryAjaxCall.aspx",
data: "sid=" $(this).attr("id"),
cache: true,
dataType: "html",
success: function(msg){
spanTemp.append(msg);
}
});
});
});


When writing jquery code, I encountered the following problems:

(1) I did not write the third line at the beginning, but at the beginning. In line 11, $(this) is directly called, and the error "Cannot assign a value to the callback function" is reported. The reason is that the object has changed after the callback, so it needs to be saved in advance;

(2) The dataType is not written, and msg cannot be returned. I don’t know why;
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template