Home  >  Article  >  Web Front-end  >  jQuery combined with ajax to dynamically load text content_jquery

jQuery combined with ajax to dynamically load text content_jquery

WBOY
WBOYOriginal
2016-05-16 15:58:191199browse

The ajax() method loads remote data through HTTP requests.

This method is the underlying AJAX implementation of jQuery. For simple and easy-to-use high-level implementations, see $.get, $.post, etc. $.ajax() returns the XMLHttpRequest object it created. In most cases you won't need to manipulate this function directly unless you need to manipulate less commonly used options for more flexibility.

In the simplest case, $.ajax() can be used directly without any parameters.

Load a text via AJAX:

jQuery code:

$(document).ready(function(){
 $("#b01").click(function(){
 htmlobj=$.ajax({url:"/jquery/test1.txt",async:false});
 $("#myDiv").html(htmlobj.responseText);
 });
});

The above is the entire content of this article, I hope you all like it.

Statement:
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