Forums

Joomla & Ajax

yuki 25 Mar, 2012
Hi, can i use Ajax in Joomla ?😑
If yes please someone give me a document explain how i can use it & thank you 🙂
GreyHead 26 Mar, 2012
Hi Yuki,

Yes you can what do you need to do? You can use Ajax with ChronoForms and there are many other extensions that use Ajax for one purpose or another.

Bob
yuki 31 Mar, 2012
Hi, 🙂
Let me explain:
I created a small application with ajax which can display a string that was written in the input text.
all is going well, but here is the result:
[attachment=0]ajax.JPG[/attachment]


Here's the code for this example:
I created two Wizard edit, the first contains:
Load JS
function maFonctionAjax(Id)
{
  var OAjax;
  if (window.XMLHttpRequest) OAjax = new XMLHttpRequest();
  else if (window.ActiveXObject) OAjax = new ActiveXObject('Microsoft.XMLHTTP'); 
  OAjax.open('POST',"index.php?option=com_chronoforms&chronoform=ajax2",true);
  OAjax.onreadystatechange = function()
  {
      if (OAjax.readyState == 4 && OAjax.status==200) 
      {
             
                    document.getElementById('msg').innerHTML=OAjax.responseText;
              
  }
  }
  OAjax.setRequestHeader('Content-type','application/x-www-form-urlencoded');
  OAjax.send('Id='+Id);                  
} 


and again Custom Code

<html><head>
<title>Areatext</title>


<body>
      <form method="post" onsubmit="maFonctionAjax(this.Id.value);return false" action="">
    <table border="0" cellspacing="0">
    <tr>
      <td colspan=2>
        Formulaire Ajax
      </td>
    </tr>
      <tr>
        <td>Id:</td>
        <td>
          <input name="Id" id="Id" type="text"></td>
      </tr>
    </table>
	 <input type="submit" value="ok"></td>
</form>
<div id="msg">

	</div>	   
		   
</body>
</html>


and the second Wizard edit contains :
Custom Code


<?php

$id=$_POST['Id'];
echo $id;

?>

I think the problem is the url :?
index.php?option=com_chronoforms&chronoform=ajax2

someone help me and thank youuu
GreyHead 01 Apr, 2012
Hi yuki,

You need to add &tmpl=component to the URL so that the template isn't loaded.

If you are working with ChronoForms then there are already some Ajax enabled elements and I suggest that you look at the MooTools Ajax functions which may save you a lot of coding.

Bob
yuki 07 Apr, 2012
Thank you thank you 😀
JJDavise 01 Oct, 2012
It's very useful topic for me , because I was interested .
This topic is locked and no more replies can be posted.