Platinum Partner

Powerfull Ajax Engine

// This is my ajax engine. You can now do everything you want with ajax.

To use it, it's very simple. Launch an ajax process like this example :


// nx is a GET request, only for small and fixed datas
nx('engine.php?action=youraction&type='+parseInt(type)+'&id='+parseInt(id)+'&nav='+parseInt(nav)+'&lw='+parseInt(LW()),'engine');

// or

nx("_engine.php?action=json","engine");


or


// np is a POST request, designed to send huge amout of variable datas
np('newpost.php','action=post&forumid='+parseInt(post[1])+'&titre='+titre+'&msg='+str+'&postid='+parseInt(post[2]),'posting');


My AJAX Engine :


function h(){var c=false,g='',d='';c=new XMLHttpRequest();this.r=function(x){d=x};this.appendData=function(a,b){g+=(g.length==0)?a+'='+escape(b):'&'+a+'='+escape(b)};this.s=function(a,b,e){b=b.toUpperCase();c.onreadystatechange=function(){if(c.readyState==4&&c.status==200){if(typeof e=='function'){e(c);return}switch(d){

case'engine':
        // an example to grab a JSON block sent by PHP. The callback will land here.
	myJSONblock.push(JSON.parse(c.responseText));
	return;break;

case'posting':
        // for example, you can forward the return of your PHP post template contained into "c.responseText" into a div with getElementById. You can do what you want. The callback will land here.
        document.getElementById('yourID').innerHTML = c.responseText;
	return;break;

}}};if(b=='GET'){c.open('GET',a);c.send(null)}else if(b=='POST'){c.open('POST',a);c.setRequestHeader('Content-Type','application/x-www-form-urlencoded');c.send(g)}return true};return this}function nx(f,x){var a=new h();a.r(x);a.s(f,'GET');return true};function np(f,a,x){var b=new h();b.r(x);b.appendData(a+'&');b.s(f,'POST');return true};


Your PHP file can look like this, for example :


".file_get_contents("forum_".$forum[(int)$_GET['type']].".php")."query ( "INSERT INTO dso_forums.posts (`id`, `parent`, `msg_parent`, `reponses`, `vues`, `note`, `auteur`, `titre`, `contenu`, `derniers`, `access`, `password`, `date`) VALUES (NULL, ".$db->qstr ( (int)$_POST['forumid'] ).", ".$db->qstr ( (int)$_POST['postid'] ).", '', '', '10', ".$db->qstr ( $_SESSION['username'] ).", ".$db->qstr ( $_POST['titre'] ).", ".$db->qstr ( $_POST['msg'] ).", '', '', '', '".date('Y-m-d H:i:s')."' )" );
	}
break;
default:}
}
?>


Some functions aren't posted here, but I will give one of mine that is very usefull by not being disturbed by char encoding :





Another functions can be posted if you request them ;=)
{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}