Can I use Ajax with Joomla 1.5.15?

I am planing to use Joomla to make web pages for some of my friends and I want to know if I can use Ajax with Joomla.

Thank you.
iscivanomarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leakim971PluritechnicianCommented:
Hello iscivanomar,

Why not? But you will need to build your own module.

Regards.
0
iscivanomarAuthor Commented:
I was just ready about Joomla yesterday and I decide to take a look of it.

I have XAMPP and Joomla install now and today I will like to create my first web page.

Could you send me an example of how to integrate Ajax in Joomla.

Thank you.
0
leakim971PluritechnicianCommented:
You have two way to develop page for Joomla :
1 - with the API of Joomla
2 - directly with the database, here an example that get list of users with an ajax function :

the page.html :
<html>
<head>
<script language="javascript">
	function getUsesr() {
		if(window.XMLHttpRequest) xmlhttp=new XMLHttpRequest(); else xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		xmlhttp.open("GET","getusers.php",false);
		xmlhttp.send(null);
		if(xmlhttp.readyState==4) {
			sUsers = document.getElementById('users');
			var users = eval('(' + xhr.responseText+ ')');
			for(var u in users) {
				var o = document.createElement('option');
				o.value = users[u].id;
				o.text = users[u].username;
				sUsers.add(o,null);
			}
		}
    }
</script>
</head>
<body onload="getUsers">
<select id="users" name="users"></select>
</body>
</html>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

leakim971PluritechnicianCommented:
And getusers.php :

(replace localhost, mysql_user, mysql_password and database_name of course with your own values)
<?PHP 
        $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); 
        if(!$link) die('Could not connect: ' . mysql_error()); 
        if(!mysql_select_db('database_name'))die('Could not select database: ' . mysql_error()); 
 
        $result = mysql_query("SELECT id, username FROM jos_users);
 
        if(!$result) die('Could not query:' . mysql_error()); 
        echo json_encode(mysql_result($result)); 
        mysql_close($link); 
?>

Open in new window

0
iscivanomarAuthor Commented:
Perfect, this is what I need to get started.

Have a good night.
0
leakim971PluritechnicianCommented:
Thanks for the points!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Joomla

From novice to tech pro — start learning today.