Home >Web Front-end >JS Tutorial >Detailed explanation of the steps to load data using ajax
This time I will bring you a detailed explanation of the steps for loading data through ajax. What are the precautions for loading data through ajax? The following is a practical case, let's take a look.
The specific code for loading data is for your reference. The specific content is as follows##1.xssj.php
<script></script> <title>无标题文档</title> <h1>显示数据</h1> <select> </select> <input> <script> $(document).ready(function(e) { //异步AJAX :执行chuli页面的同时,继续执行下面代码。效率高,不用等待,继续执行下面代码 //异步和同步 同步:效率不高,不能同时执行两件事情 $.ajax({ //async:false,//把异步关闭,相当于开启同步 url:"xschuli.php", dataType:"TEXT", //complete: function(){},//执行完成之后执行 //beforeSend: function(){},//发送处理请求之前,自动处理此方法 complete和beforeSend可以实现进度条 //error: function(){},//如果出错了执行此方法 success: function(data){ //success: function(){}是执行完成之前执行 var hang = data.split("|"); var str = ""; for(var i=0;i<hang.length;i++) { var lie = hang[i].split("^"); str = str+"<option value='"+lie[0]+"'>"+lie[1]+""; } $("#sel").html(str); //alert($("#sel").val()); } }); //alert($("#sel").val()); $("#qu").click(function(){ alert($("#sel").val()); }) }); </script>
The above is the detailed content of Detailed explanation of the steps to load data using ajax. For more information, please follow other related articles on the PHP Chinese website!