Jump to content

Ajax & PHP


why not

Recommended Posts

Hi ! I Have Problem With send data form  in ajax loading page ( DIV )  without refresh page .  problem is  : not load page - not load wis editor - and not send time & date

My Form :

 (.tpl file)
<form name="EDITFORM" method="POST" action="{S_ACTION}" enctype="multipart/form-data">
<input type="hidden" id="used_files" name="used_files" value="{USED_FILES}">
<input type="hidden" name="page_id" value="{PAGE_ID}">
.... FIELD ....
<input class=submit type="submit" name="submit" value="{L_BUTTON}">

NOTE : {S_ACTION} = $Session->append_sid(ACP_INDEX .'?mod=article&act=edit&id='. $id . $this->filter['url_append'] .'&page='. $this->page),

 

AJAX CODE :

function show_id(id){    if(document.getElementById(id)){    	document.getElementById(id).style.display ='';	}}function write_in_id(id,note){ 	if(document.getElementById(id)){  		show_id(id); 		document.getElementById(id).innerHTML=note;	}}function hide_id(id){    if(document.getElementById(id)){		document.getElementById(id).style.display ='none';	}}function page_loader(this_page){	main_ajax_do(this_page, 'main_page', '');}function write_in_blank_id(id){ 	if(document.getElementById(id)){  		show_id(id); 		document.getElementById(id).innerHTML=' ';	}}function get_value_for_ajax(this_id){	if(! document.getElementById(this_id) ){		return '';	}else if(document.getElementById(this_id).type == 'checkbox'){        return document.getElementById(this_id).checked;	}else{        return encodeURIComponent(replace_for_ajax(document.getElementById(this_id).value));	}}function replace_for_ajax(note){	note= note.replace(/&/g,"**am**");	note= note.replace(/=/g,"**m**");	note= note.replace(/\+/g,"**jam**");	return note;}function loading_effect(k){	ht = document.getElementsByTagName("html");	if(k==1){	    ht[0].style.cursor = 'wait';	}else{	    ht[0].style.cursor = 'auto';	}}function main_ajax_do(url , thisid, post){ 	var xmlhttp=false;        show_id(thisid); write_in_id(thisid ,'<center><img src="portal/images/loading.gif" width="32" height="32" alt="Loading... Please Wait..." border="0"></center>') ;       		loading_effect(1);        /*@cc_on @*/        /*@if (@_jscript_version >= 5)        	try {                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');                }                 catch (e) {            try {xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');} 				catch (E) {                 xmlhttp = false;                 }    		}    	@end @*/    if(!xmlhttp) { xmlhttp=new XMLHttpRequest();}	xmlhttp.open('POST', url, true);        xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); post=post+'&my_time='+escape(new Date().getTime());        xmlhttp.send(post);         xmlhttp.onreadystatechange = function() {             if(xmlhttp.readyState == 4  && xmlhttp.status == 200){                document.getElementById(thisid).innerHTML =xmlhttp.responseText;                loading_effect(0);             }        }}

 

Any idea for fix this problem or any code for loading page ? thanks regards

Link to comment
https://forums.phpfreaks.com/topic/122519-ajax-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.