您好,欢迎访问一九零五行业门户网

jquery如何实现ajax技术3:$.get()

今天要向大家介绍的是jquery中的$.get()。它同样能够让我们以非常少的代码量完成网站开发中的ajax需求。
  $.get()函数的参数和我们在《jquery如何实现ajax技术2:$.post()》中介绍的$.post()参数相同。具体如下:
  $.get(url,data,callback,type)
  url---待载入页面的 url 地址。
  data---待发送 key / value 参数。
  callback---载入成功时回调函数。
  type---返回内容格式,xml, html, script, json, text, _default。
  下面举一个实际例子:
  ===============================================================
  ajax.html
  <html>
  <head>
  <title>$.ajax的应用</title>
  <script type="text/javascript" language="javascript" src="./js/jquery.js"></script>
  <script type="text/javascript" language="javascript">
  $(document).ready(function(){
    $('#bot_1').click(function(){
      $.get('ajax.php',{web:mysql100},function(data,st){$(div).html(data);})
    })
  })
  </script>
  </head>
  <center><h2>$.ajax的应用</h2></center>
  <center><div>这是需要显示的地方</div></center>
  <center><button id="bot_1">点击我吧</button></center>
  </html>
  ===============================================================
  ajax.php
  <?php
echo '您要访问的网站是'.$_get['web'];
?>
 以上就是jquery如何实现ajax技术3:$.get()的内容。
其它类似信息

推荐信息