ajaxÌá½»±íµ¥
ajaxÌá½»±íµ¥
¹Ø¼ü×Ö: ajax
function ajaxSubmitForm(form, resultDivId) {
var elements = form.elements;// Enumeration the form elements
var element;
var i;
var postContent = "";// Form contents need to submit
for(i=0;i<elements.length;++i) {
var element=elements[i];
if(element.type=="text" || element.type=="textarea" || element.type=="hidden") {
postContent += encodeURIComponent(element.name) + "=" + encodeURIComponent(element.value) + "&";
}
else if(element.type=="select-one"||element.type=="select-multiple") {
var options=element.options,j,item;
for(j=0;j<options.length;++j){
item=options[j];
if(item.selected) {
postContent += encodeURIComponent(element.name) + "=" + encodeURIComponent(item.value) + "&"; &n
Ïà¹ØÎĵµ£º
ajax¼¼ÊõÊÇʹҳÃæÄֲܾ¿Ë¢ÐµÄÒ»ÖÖ¼¼Êõ,È«³ÆÓ¦¸ÃÊÇasynchronous JavaScript and xml´Ó¼¸¸öµ¥´Ê¾ÍÖªµÀËüµÄÇëÇóÏìÓ¦µÄ´¦ÀíÊÇÒì²½µÄ,¶øÇÒʹÓõÄÊÇJavaScriptºÍxml¼¼Êõ.
ÎÒÃÇÔÚjavaÖÐʹÓÃajax¼¼Êõ×î¼òµ¥µÄÊÇʹÓÃËüµÄÒ»¸ö¿ò¼ÜdwrÖ»Òªµ¼ÈëÕâ¸ö°ü,×öÏàÓ¦µÄÅäÖÃ,¿É ......
AjaxµÄIE»º´æÎÊÌ⣬»áÔì³ÉÓÃopenʱÓÃget·½·¨²»ÄÜÖظ´Ìá½»,µ¼Ö»ñÈ¡²»µ½ÊµÊ±µÄÐÅÏ¢¡£½â¾öµÄ°ì·¨ÓÐÒÔϼ¸ÖÖ£º
1.¿Í»§¶ËÔÚurlºóÌí¼ÓËæ»úÊý.
new Date().getTime()»òÕßMath.Random()
»òÕßËÍÇëÇóÇ°¼ÓÉÏ
XMLHttpRequest.setRequestHeader("If-Modified-Since","0")
2.»òÕßÓÃpost·½·¨Ìá½»  ......
ÎҵĴºÇï³ÕÃεڶþ²½£º
дһ¸ö ͨÓÃµÄ ¶ÔÏó ÁÐ±í £¬»¹ °üº¬ ËÑË÷ºÍ ÊôÐÔ¹ýÂË¡£
¾ßÌåµÄЧ¹ûÊÇ£º
µ±Ð ҵÎñ Ìí¼ÓÒ»¸ö ±íµÄʱºò£¬Ö»ÐèÒªÔÚ ¶ÔÏóÄ£ÐÍÀïµÄ Ìí¼ÓÒ»¸ö model
ºǫ́¼¸ºõ²»Ðèд´úÂë¡£
(ÎÒÊǺǫ́£º¼¤¶¯ÈËÐÄ£¡)
µ÷ÓõĶÔÏ󣬵ڼ¸Ò³£¬ÊôÐ﵀ ¹ýÂË ºÍËÑË÷È«ÊÇ Ç°Ì¨µÄAjax²ÎÊý¿ØÖÆ
(ÎÒÊÇǰ̨£º#$!@#$%$^#$% ......
±ÈÈçÒª¸øÓû§±¨¸æÒ»¸ö´íÎó£¬ÓÃÏÂÃæµÄ·½·¨£º
ʹÓÃset_error_handlerÉèÖÃ×Ô¼ºµÄ´íÎó´¦Àíº¯Êý£¬ÔÚ±¨´íµÄµØ·½Ê¹ÓÃtrigger_error£¬ÔÚ×Ô¶¨ÒåµÄ´íÎó´¦Àíº¯ÊýÖиøÓû§ÏÔʾһ¸ö³ö´íÐÅÏ¢Ò³Ãæ¡£
µ«
ÊÇÈç¹ûµ÷ÓÃtrigger_errorµÄÕâ¸öÒ³ÃæÊDZ»Ò»´ÎajaxÇëÇó´¥·¢µÄ£¬ÄÇôajax·µ»Øºó½«µÃµ½Ò»´ó¶ÑÓÃÓÚÏÔʾ´íÎóµÄhtml´úÂë¡£¶øÒ»°ã
ajaxµ÷Óö ......