redirection does not work in i and Firefox but works in chrome


my login form execute only in chrome. it doeasn't work in IE and firefox. it understand that this is the correct username but it doesn't redirect to the page. I use ajax and joomla. this is my code:

function Send()



<form name="loginForm" id="loginForm" method="post">
<label>Username:</label><input type="text" name="username" id="username"  /><br />
<label>Password:</label><input type="password" name="password" id="password" /><br />
<input type="button" onclick="Send();" value="login" name="loginSubmit" id="login"  />

the code of page in address: index.php?option=com_market&view=login&format=raw

if(isset($_POST['Username'])) {
    $db = JFactory::getDBO();
    $pass = md5($_POST['Pass']);
    $query ="select id from sb5qt_market_users where username='$Username' and     password='$pass'";
    $rows = $db->getNumRows();
    $result = $db->loadResult();

    if ($rows == 0) {
        echo "invalid username or password";
    } else {
        echo  '<META http-equiv="refresh" content="0;URL=">';

Seems to me like an odd way of redirecting and I'm not really surprised browsers are having trouble with it.

You could try this:

in PHP

if($rows == 0)
   echo json_encode(array("error" => "invalid username or password", "redirect" => ""));
   echo json_encode(array("error" => "", "redirect" => ""));

Then in your Javascript something like...

    url: 'index.php?option=com_market&view=login&format=raw',
    data: 'Username=' + jQuery("#username").val() + "&Pass=" + jQuery("#password").val(),
    type: 'post',
    dataType: 'json',
    success: function(data)
       if (data['error']) {

       if (data['redirect']) {
         location.href = data['redirect'];

I haven't tested any of that but you can see what I'm getting at...