I am attempting to make an jquery ajax modal login module for joomla 1.6. There must be to ensure that the qualifications passed put ajax to become proofed with a php file. But fortunately does not appear to become performed. My ajax appears to be the result is

type: "POST",
url: "do-login.php",  // Send the login info to this page
data: "username="+$('#username').val()+"&password="+$('#password').val(),   
success: function(msg){  }

and also the receiver php file

// No direct access to this file
/* Initialize Joomla framework */

defined('_JEXEC') or die;
jimport( 'joomla.application.application' );

$mainframe = JFactory::getApplication();
$post_username = JRequest::getVar($username);
$post_password = JRequest::getVar($password);

$data['username'] =$post_username;
$data['password'] = $post_password;

$mainframe->login($data, $option);
if (!JError::isError($error)) {
        echo 'OK';
    } else {
          echo '<div id="notification_error">The login info is not correct.</div>';



If I am getting rid of joomla defined(_JEXEC)code than aren't loaded the particular classes.

I figured so. Everything needs to undergo joomla's index.php. But how about if I am while using standard joomla com_customers component can one achieve my objectives?

Perhaps you have attempted the next format for the publish query?

$.post('do-login.php', { username: $('#username').val(), password: $('#password').val()}, function (data) {


You can't call the PHP files directly you are attempting to just do exactly what the defined('_JEXEC') or die; bit is made to prevent )

You are gonna need to develop a aspect of receive individuals calls, then spit back the response you need to display. Presuming (with regard to discussion) you build com_ajax_login as the component, your JavaScript would seem like this:

$.post('index.php', {
    option: 'com_ajax_login',
    tmpl: 'component',
    format: 'raw',
    username: $('#username').val(),
    password: $('#password').val(),

Once the component spits the response, it'll get passed into that anonymous function using the parameter response, you'll be able to put it wherever you would like (like $('#your_login_box').html(response); for instance). Also note the format and tmpl variables within the request: these prevent Joomla from coming back the entire template.

You can virtually copy do-login.php into components/com_ajax_login/ajax_login.php as-is (although you will need to either install the component with the Joomla installer or make an entry in jos_extensions).