Using Mootools Request.HTML response Javascript using $exec

Javascript frameworks are great, no matter which one you use their all built to do more, quickly.

I use Mootools for most of my JS needs, and something is I often use is the AJAX request functionality.

Today I needed to send not only HTML back, but Javascript.

Here are the steps I needed to follow to not only return my Javascript, but to attach it to my response with the Mootools function ‘$exec’

My HTML

<a id="update" href="/ajax.php?step=hello&amp;id=1">Update</a>

My Mootoold Javascript

	<script type="text/javascript"><!--mce:0--></script>

Our Request Handler PHP script

<script type="text/javascript"><!--mce:1--></script>
 
<!-- Return our Response-->
 
&lt; ?php
 
	/* QUERY OUR RECORDS FROM OUR GET DATA */
 
	$response = mysql_get_data_function($_GET);
 
	echo($response);
 
?&gt;

Final Response

After running this ‘update’ script, we will have displayed information based on our GET data in the div ‘container’, removed our update link, shown a success message, and styled everything with out response javascript, all thanks to our nifty Mootools $exec function.

This entry was posted in Code, javascript, Technology, Uncategorized, work and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">