码迷,mamicode.com
首页 > Web开发 > 详细

jquery ajax

时间:2014-10-23 16:11:36      阅读:127      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   os   ar   sp   div   

普通ajax请求:
$(document).ready(function() { $.ajax({ url:
/path/to/file, type: default GET (Other values: POST), dataType: default: Intelligent Guess (Other values: xml, json, script, or html), data: {param1: value1}, }) });

jsonp跨域:
$(document).ready(function(){
        $.ajax({
             url:‘http://192.168.9.5/jsonp_proc.asp‘,
             dataType:"jsonp",
             jsonp:"jsonpcallback",
             success:function(data){
                 var $ul = $("<ul></ul>");
                 $.each(data,function(i,v){
                     $("<li/>").text(v["id"] + " " + v["name"]).appendTo($ul)
                 });
                 $("#res").append($ul);
             }
        });
    });

getjson普通请求:
var url="http://localhost:2589/a.ashx";
$(function(){
  $.getJSON(url,function(data){
    alert (data.Name);
  })
}); 

getjson跨域请求:
var url="http://localhost:2589/a.ashx?callback=?";
$(function(){
  $.getJSON(url,function(data){
    alert (data.Name);
  })
}); 

 

jquery ajax

标签:style   blog   http   color   io   os   ar   sp   div   

原文地址:http://www.cnblogs.com/LoveJulin/p/4045772.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!