[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 431
  • Last Modified:

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.
0
iscivanomar
Asked:
iscivanomar
  • 4
  • 2
1 Solution
 
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now