顯示具有 Ajax 標籤的文章。 顯示所有文章
顯示具有 Ajax 標籤的文章。 顯示所有文章

2012年12月11日

AJax Loading

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="Pages_test" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script type="text/javascript" src="<%=Page.ResolveUrl("~/") %>js/jquery-1.8.3.min.js"></script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <img id="img1" src="<%=Page.ResolveUrl("~/") %>images/ajax-loader.gif" /><input id="btn1" type="button" value="Click" /><br />
        <img id="img2" src="<%=Page.ResolveUrl("~/") %>images/ajax-loader.gif" /><input id="btn2" type="button" value="Click" /><br />
        <img id="img3" src="<%=Page.ResolveUrl("~/") %>images/ajax-loader.gif" /><input id="btn3" type="button" value="Click" /><br />
    </div>
    </form>
</body>
</html>

$(function () {
        $('img').hide();
        $('img').hide();

        $('#btn1').click(function () {
            $('#img1').show();
            $.ajax({
                url: "/mjib/Services/CaseManageServices.ashx",
                type: 'POST',
                cache: false,
                data: {
                    OperationType: 'test'
                },
                success: function (response) {
                    $('#img1').hide();
                },
                error: function (response) {
                    $('#img1').hide();
                }
            });
        });

        $('#btn2').click(function () {
            $('#img2').show();
            $.ajax({
                url: "/mjib/Services/CaseManageServices.ashx",
                type: 'POST',
                cache: false,
                data: {
                    OperationType: 'test'
                },
                success: function (response) {
                    $('#img2').hide();
                },
                error: function (response) {
                    $('#img2').hide();
                }
            });
        });

        $('#btn3').click(function () {
            $('#img3').show();
            $.ajax({
                url: "/mjib/Services/CaseManageServices.ashx",
                type: 'POST',
                cache: false,
                data: {
                    OperationType: 'test'
                },
                success: function (response) {
                    $('#img3').hide();
                },
                error: function (response) {
                    $('#img3').hide();
                }
            });
        });
    });
</script>

2012年9月14日

Ajax 後 網頁重新導向


async
類型:Boolean
默認值: true。
默認設置下,所有請求均為異步請求。如果需要發送同步請求,請將此選項設置為 false。
注意,同步請求將鎖住瀏覽器,用戶其它操作必須等待請求完成才可以執行。

$.ajax({
    url: '/usercontrols/ExportHighchartPhotoServices.ashx',
    type: 'POST',
    async: false,
    data: { ... },
    error: function (xhr, ajaxOptions, thrownError) {
        ...
    },
    success: function (response) {
        ...
    }
});

jQuery ajax - ajax() 方法

2012年8月23日

Ajax call Webservice

$.ajax({
   type: "POST",
   url: "../../WebService.asmx/FindPerson",
   data: params,                                   // 參數
   contentType: "application/json; charset=utf-8", // 參數格式
   dataType: "json",                               // 回傳格式 
   success: function(response) {
     // 將 WEB SERVICE 回傳的字串轉為物件
     var jsonObj = $.parseJSON(response.d);
  
     // 使用 chrome 按 F12 選擇 console 即可看到結果  
     console.log("Hello, I am " + jsonObj.name);
   }
   ,failure: function(msg) { }
   ,error: function(msg) { }
});

http://jax-work-archive.blogspot.tw/2011/09/jquery-textarea.html