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 的學習 | 豬窩

Photorealistic dragonfly tattoo - Want a truly realistic
looking dragonfly tattoo. In case of Dexter, all episodes, that are aired weekly, co-relate for the storyline
of not just the previous episode but the next episode
as well. After choosing the ring using a fiber optic camera
the restaurant agreed to let a plumbing and excavating company
jackhammer the bottom to reach the ring deep inside the sewer.

作者 Afju.reporter-x.life @ 22:13, 2019-03-13

ajax 的學習 | 豬窩

People observe the rave reviews and are touched by the
great wish to watch the given movie on big screen. Answer:
Arcada, California - Useless Fact: Brothers Dick and Mac Mc - Donald
open a hot dog stand referred to as Airdome in Arcadia, California.
Velazquez inside 17th century and current young painters in good sized quantities reflected the Spanish art background and skills.

作者 http://Alfateatre.asociaciones.alfafar.es/ @ 20:13, 2019-03-23

ajax 的學習 | 豬窩

Hashtags will then be used to create "groupings" on Twitter, and
never have to change the basic service. Thank you,
Patra residents (especially Gwgw and Sotiris) for bringing
to New Zealand an atmosphere of your property town. 3b - This version provides for the transmitting of Dolby True - HD and DTS-HD Audio, that
are used with Blu-ray players.

作者 Layla @ 12:32, 2019-03-30

ajax 的學習 | 豬窩

If you are trying to utilize those secrets while using the online dating services opportunities then you've got more chances to acquire your date partner.

The internet dating arena has grown immensely weight loss folks are depending upon internet
to satisfy new people, find their someone special, friendship and many more activities.
Once they are successful of their career and
accomplish anything they want, they realize the importance of marriage.

作者 Emilie @ 07:28, 2019-03-31

ajax 的學習 | 豬窩

For instance, if you're a raw beginner, you will end up hunting for a
video showing you ways to tune your guitar, and maybe a
lesson showing you how to change your guitar strings.

But before you get involved with exercising before your TV;
it will greatly help if you get to comprehend your mechanism.
Abstraction - Abstraction is a generic term for art it doesn't represent recognizable objects.

作者 https://Lexa.En-Joy.today/ @ 08:29, 2019-04-02
發表迴響
 authimage