Ms7 Search
Google 搜尋 翻譯
calendar
« 九月 2024 »
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            
近期文章
文章分類
網站連結
Syndicate

« | »

ajax 的學習

2007-11-08 @ 11:24 in PHP, JavaScript, Sql

這幾天都在研究 ajax 的用法,AJAX全稱為「Asynchronous JavaScript and XML」(非同步JavaScript和XML),是指一種創建交互式網頁應用的網頁開發技術,最好的地方是向server提出需求,只要更新部分網頁內容,不用全部更新,並且server在處理時,client也可以動作,server處理完,自動更新,client不用等待,所以叫非同步,它必需有 dom,javascript,xml的基礎,對我來講有點難,看了幾篇教學,只大約有個概念,等那天故意用它寫個網頁程式試試...

下面好像是從 ibm 網站看來的例題,再加上自己的一點備註 

<script language="javascript" type="text/javascript">
var request = false;
try
    {   request = new XMLHttpRequest(); }
catch(trymicrosoft)
    {
    try
        {   request = new ActiveXObject("Msxml2.XMLHTTP");  }
    catch(othermicrosoft)
        {
        try
            {   request = new ActiveXObject("Microsoft.XMLHTTP");   }
        catch(failed)
            {   request = false;    }
        }
    }
if(!request)
    alert("Error initializing XMLHttpRequest!");

function getCustomerInfo()
    {
// Get 方式
    var phone = document.getElementById("phone").value;
    var url = "lookupCustomer.php?phone=" + escape(phone);
    request.open("GET",url,true);
    request.onreadystatechange = updatePage;
    request.send(null);
/* Post 方式
    var phone = document.getElementById("phone").value;
    var url = "lookupCustomer.php";
    request.onreadystatechange = updatePage;
    request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    request.send("phone="+phone+"&item="+itemCode);
*/
    }

function updatePage()
    {
    if(request.readyState == 4)
        {
        if(request.status == 200)
            {
            var response = request.responseText.split("|");  //server必須送回  "字串 | 字串 | ..."格式 ,如果是 php 用 echo 送回
            document.getElementById("order").value = response[0];
            document.getElementById("address").innerHTML = response[1].replace(/\n/g,"");
            }
        else
            {   alert("Error: status code is " + request.status);   }
        }
    }
</script>

<body>
    <p><img src="breakneck-logo_4c.gif" alt="Break Neck Pizza" /></p>
    <form action="POST">
    <p>Enter your phone number:

    <input type="text" size="14" name="phone" id="phone"
          onChange="getCustomerInfo();" />

    </p>
    <p>Your order will be delivered to:</p>
    <div id="address" ></div>
    <p>Type your order in here:</p>
    <p><textarea name="order" rows="6" cols="50" id="order"></textarea></p>
    <p><input type="submit" value="Order Pizza" id="submit" /></p>
    </form>
 </body>

迴響

ajax 的學習 | 豬窩

This device also governs the flow of power in the photovoltaic array
towards the grid and vice-versa. This type of technology utilizes specialized equipment, teaching materials and services which will enable they perform and function inside their surroundings.
Allowing consumers to find the charity, or perhaps using a revolving
report on charities, finds being a marketing incentive.

作者 http://fashionbangladeshltd.com/ @ 01:01, 2017-06-18

ajax 的學習 | 豬窩

This device also governs the flow of power from the photovoltaic
array for the grid and vice-versa. One other thing that you
might want to consider is limiting access for the network, notably if you take part in any kind of secure
printing or if you've got aspects of the network that are
for secure files. But Apple possesses its own idea about the way to watch video, and possesses absolutely nothing to do
with standards that anybody else creates.

作者 chakwaltimes.com @ 02:49, 2017-06-18

ajax 的學習 | 豬窩

This device also governs the flow of power in the photovoltaic array on the grid and vice-versa.
One other thing which you are required to consider is limiting access on the
network, particularly if take part in almost any secure printing
or if you might have regions of the network which can be for secure
files. Silicon is among the most common of the materials accustomed to generate electrical current if
it's exposed to sunlight.

作者 http://bdtechstore.com/ @ 04:21, 2017-06-19

ajax 的學習 | 豬窩

Direct the scene to your blog post so they can share their thoughts
about your statement. Make any final announcements (by way of example, the following webinar in the series).

Allowing consumers to choose the charity, or perhaps having
a revolving listing of charities, results in like a marketing incentive.

作者 bigsmilego.com @ 10:20, 2017-06-19

ajax 的學習 | 豬窩

In fighting against QR codes, there are three significant
reasons being shown to keep the theory these two-dimensional barcodes just aren't clicking with Americans:
. One other thing that you desire to take into consideration is limiting access on the network,
specifically if you take part in almost any secure printing or if you have areas of the network which are for
secure files. Roughly equal amounts of the three primary colors give rise towards the perception of white.

作者 lchstitantimes.com @ 07:53, 2017-06-20
發表迴響
 authimage