1. Trang chủ
  2. » Công Nghệ Thông Tin

Manual programming Experience Handbook part 136 pot

6 218 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Nội dung

<input type="text" id="Sender_Name" /> // long descriptive names that will not be used as <input type="text" id="Sender_Email" /> // javascript variable names are a good habit here <input type="button" value="send" onclick="javascript:submitform('processform. php')"/> </form> Wrapper code for Asynchronous requests PHP Code: var req1=createXHRobj() var req2=createXHRobj() function asynXHR(url, reqobj, action) { reqobj.onreadystatechange=action reqobj.open("GET", url, true) reqobj.send("") } function responseIsReady(reqobj) { if (reqobj.readyState==4) if (reqobj.status==200) return true else { alert("ERROR: STATUS RESPONSE "+reqobj.status) return true // let the call proceed so we know which // call the status error occurred in } else return false } // each callback function must use its own request object var req1, req2 function showstock() { if (responseIsReady(req1)) alert("stock price: $"+req1.responseText) /* IE can't reuse the XHR object, you are required to clean up and create a new on e */ req1=null req1=createXHRobj() } function showtemp() { if (responseIsReady(req2)) alert("It's "+req2.responseText+" celsius") /* IE can't reuse the XHR object, you are required to clean up and create a new on e */ req2=null req2=createXHRobj() } asynXHR("price.php?stock=GOOG",req1,showstock) asynXHR("temperature.php?city=Singapore",req2,showtemp) One.N(UDS) web Portal pro với công nghệ AJAX đây trong một lúc tình cờ cũng như la may mắn và kèm theo những kiến thức mình hie763u được về công nghệ AJAX, mình đã phát hiện 1 web portal có chưa trong đó những công nghệ mà mấy anh gọi là AJAX, có thể đây không phải là được xây dựng 100% bằng AJAX, nhưng mình nhắm chừng nó cũng cở 30% đến 40% rồi đó đặc biệt là cái cpannel của nó, thật tuyêt vời , mới vô trang admin control nó là chúng ta đã cảm nhận được hơi thở của web 2.0, có là web portal mambo, các bạn có thể vào trang web http://demo.mamboserver.com/ này của nó để tham khảo, các bạn của cũng thể vô admini control pannel để xem qua coi sao, use và pass là admin, đặc biệt mambo có hỗ trợ tiếng việt, đây là 1 web portal cũng rất phổ biến ở việt nam , nhưng việc thằng này gần đây update 1 phần nào đó công nghệ web 2.0 thì ít ai để ý đến, trong trang chủ của nó cũng có đề cập đến vấn đề pluin những công nghệ AJAX vô, gồm có javascript, XML, XMLhttp, DOTIT gì đó nhiều lắm, các bạn có thể vô trng homepage của nó để tham khảo và dơn về chạy thử, nhưng rất tiết là nó vẫn chưa có forum, và việc thiết kế forum đang nằm trong tằm develope của nó, hy vọng là sẽ so81m hoàn thành, nào sao chúng ta còn không nahnh chống down về dùng thử nhỉ, biềt đâu bạn sẽ là 1 trong những ngườo đi tiên phong trong việc xây dựng những ứng dụng portal dựa trên nền tảng web 2.0, hãy nhanh chân và hãy tự tin vào chính mình nào thaivinhhuy(UDS) [Ví dụ] AJAX Loader - Tải nội dung một trang web khác vào một khung trên trang mình! Bạn xây dựng một trang web và bạn muốn trên đó 1 khung nội dung của bạn chứa 1 trang web khác (html, php, xml, ). Điều này có thể thực hiện dễ dàng với thẻ iframe, nhưng nếu bạn muốn dùng AJAX để tải trang đó (tức khi hiện lên thì nó đã load 100%) bạn có thể làm như sau: Trước hết bạn tạo 1 file ajaxLoader.js có nội dung như sau: PHP Code: function ajaxLoader(url,id) { if (document.getElementById) { var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP" ) : new XMLHttpRequest(); } if (x) { x.onreadystatechange = function() { if (x.readyState == 4 && x.status == 200) { el = document.getElementById(id); el.innerHTML = x.responseText; } } x.open("GET", url, true); x.send(null); } } Bạn save cùng thư mục trang web bạn đang tạo. Mở trang web bạn đang tạo lên, Chèn đoạn code sau vào giữa <head> và </head> PHP Code: <script language="javascript" src="ajaxLoader.js"> </script> <style type="text/css"> #contentLYR { position:absolute; width:100%; // tùy chọn height:100%; // tùy chọn z-index:1; // tùy chọn left: 0px; // tùy chọn top: 200px; // tùy chọn } </style> Tại thẻ <body> bạn khai báo như sau: Code: <body onload="ajaxLoader('test.htm','contentLYR')"> (Chú ý test.html là trang được load.) Trong thẻ <body> bạn chèn: Code: <div id="contentLYR"> Loading </div> Hãy thử và cảm nhận. Ngocha85(UDS) Upload với Ajax và PHP Đầu tiên là list một số tut về file uploader với Ajax: http://www.ajaxtopics.com/fileuploader.html Sau là một class mang tên Ajax File Uploader dành cho PHP: http://www.phpclasses.org/browse/package/2759.html Hy vọng chúng giúp gì được cho bạn. Identical(UDS) Ajax tutorials Link Post Here 60 Ajax tutorials Từ cơ bản đến nâng cao Dễ cho anh em tham khảo Code: http://www.maxkiesler.com/index.php/weblog/comments/60_more_helpful_ajax_t utorial One.N(UDS) Anh em coi mấy cái này đi, ^^ http://www.webreference.com/programming/ajax_tech/ http://www.maxkiesler.com/index.php/ jax_tutorials/ http://www.maxkiesler.com/index.php/ jax_tutorials/ http://ajaxpatterns.org http://ajaxpatterns.org/Ajax_Frameworks http://en.wikipedia.org/wiki/AJAX http://www.fiftyfoureleven.com/resou xmlhttprequest http://msdn.microsoft.com/library/de de7a711b38.asp http://developer.apple.com/internet/ mlhttpreq.html http://ajaxblog.com www.ajaxian.com http://weblogs.asp.net/mschwarz/archive/2005/11.aspx www.robsanheim.com/category/software/ajax http://groups.google.com/group/ajax-world . http://www.maxkiesler.com/index.php/weblog/comments/60_more_helpful_ajax_t utorial One.N(UDS) Anh em coi mấy cái này đi, ^^ http://www.webreference.com /programming/ ajax_tech/ http://www.maxkiesler.com/index.php/ jax_tutorials/ http://www.maxkiesler.com/index.php/

Ngày đăng: 06/07/2014, 01:20