Jquery page Ajax method $.load function to use the introduction

  • 2020-03-30 04:08:08
  • OfStack

The load of grammar

$(" selector "). The load (" url ", function (the responseText, statusText, xmlhttprequest));

When a page is loaded, it is important for the user to display the corresponding prompt based on the statusText status if an error occurs.

Example, load the post

The following code


<div id=btnAjaxPost> Click on the I </div>
<div id=divResult> Content loading </div> $("#btnAjaxPost").click(function(event)
{
var username = $("#username").val();
//Send a Post request
$("#divResult").load("$(www.jb51.net){ctx}/jqueryLoad", { "username": username});
});

Example, the load get method

The following code


<div id=in_head> Content loading </head>
<script language="javascript">$('#in_head').load('ajaxlogin.php?cityid=1208');</script>

Ajax method $.load garbled

Load is generally caused by the two page coding not affected, the processing method is

1. The code of my display page index. HTML is uft-8;
2. The encoding of my static page foot-html is uft-8;

$(" # index_foot_container "). The load (" foot. HTML ");


Related articles: