Hello,
I am doing simple Jquery ajax post to php and I am very new to three languages. Any suggestion or guidance.

I have two iframes
1. iframe 1 is Navigation menu(loaded with flash menu).
<iframe name=”menu”/>
2. iframe 2 is load the web page.
<iframe name=”page_load”/>
When I click the navigation menu the corresponding web page loaded.
In one part, when I clicked the navigation “menu” the login_reg.php page open in page_load.
The login_reg page has two parts of form,
1. In one, registration process is done
<form id=”registration”/>
2. In another, login is done.
<form id=”login_form”/>

When I submit the login_form, it check the login and password.if it success, both parent iframes should be reloaded by corresponding src attribute,

MY problem:

  1. But sometimes it getting refresh without any changes and.
  2. Mozilla, safari it doesn’t works and just page is get refreshed.

My Jquery and ajax script:

$(document).ready(function(){

$("form#login_form").submit(function() { 

alert('this method is called');

var user_id=$('#user_id').val();
var p_word=$('#p_word').val();

if(user_id.length >= 4 && p_word.length>=4)
{

    $.ajax({  
    type: "POST",  
    url: "login-exec.php",  
    data: "user_id="+ user_id + "&p_word="+p_word,  

    success: function(msg){  


   alert('it entered the message');

    if(msg == 'OK')
    { 

    parent.load_right('pub@lic_profile/@_profile/all_@_all/flashmo_203_modified.swf');

           parent.load_left('pub@lic_profile/@_profile/all_@_all/horizontal_menu/flashmo_114_horizontal_03.swf');
    }  
    else  if(msg=='NOT')
    {  
alert('the message is alert is not OK');

    }  


 } 

  }); 

}
else
    {
    $("#status1").html('<font color="red">The username should have at least <strong>4</strong> characters.</font>');
    $("#username").removeClass('object_ok'); 
    $("#username").addClass("object_error");
    }

});


PHP script:
<?php
include_once dirname(__FILE__).'/sql.php';

$link = mysql_connect(server, user, password);

    if(!$link)
    {
        die('Failed to connect to server: ' . mysql_error());
    }   

    $db = mysql_select_db(DB_CATALOG);
    if(!$db) {
        die("Unable to select database");
    }

    function clean($str) {
        $str = @trim($str);
        if(get_magic_quotes_gpc()) {
            $str = stripslashes($str);
        }
        return mysql_real_escape_string($str);
    }
    $username = clean($_POST['user_id']);
    $password = clean($_POST['p_word']);
    $qry="select * from customer_se where username='".$username."' and password='".md5($password)."'";

    $result=mysql_query($qry);
    if(mysql_num_rows($result)) 
        {
            echo 'OK';

        }
        else 
         {
            echo 'NOT';

        }

?>

Thanks in advance,

With Regards,
Eswaran Saravanan,
University west,
Sweden

Javscript error. Curly braces are unbalanced. 8x{ but only 7x} .

Airshow

Sorry I am missed one Curly braces here when I am copying the code from editor.But its not a java script error.But in the form I am correctly given the Curly braces.Thats not my problem.

MY problem is,

1)Some times in Internet explorer, the submit method is called and suddenly only the page get refreshed not reloading the iframes.
2)Also in Mozila and Safari it call the submit method in jquery and get refreshed without reloading the iframes.

Thanks in advance,

With Regards,
Eswaran Saravanan,
University west,
Sweden

Eswar,

Thats not my problem.

I know that's not your problem but it is my problem in trying to replicate your problem!

I can make a calculated guess as to where the missing line belongs but I may be wrong.

Airshow

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.