JQuery中ajax請求
來源:互聯網
上載者:User
關於Jquery中的ajax請求 ,我並沒做乾的的說詞,而是給出我自己做的實實在在的例子,供大家參考。
<script type="text/javascript" src ="jquery-1[1].2.6.js"></script>
<script >
function button1()
{
$("#demo").load("http://localhost/DedecmsV53/upload/");
}
function button2()
{
$.get("jquery.htm",function (uname){
document .getElementById ("demo").innerHTML =uname;
});
}
function button4()
{
$.post("jquery.htm",function (uname){
document .getElementById ("demo").innerHTML =uname;
});
}
function button3()
{
$.ajax({type: "GET",
url: "WebForm1.aspx"
});
}
function button5()
{
$.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=?",
function(data){
$.each(data.items, function(i,item){$("<img/>").attr("src", item.media.m).appendTo("#demo");
if ( i == 3 ) return false;});});
}
function button6()
{
$.ajax({
contentType:"application/json",
type: "POST",
url: "WebService.asmx/HelloWorld",
data:"{'name':'張三'}",
dataType: 'json',
success: function(msq){
alert (msq.d);
}
});
}
$(function ()
{
$("div").css({color:"red"})//樣式
});
</script>