hi, i am new to jquery though im learning,together with ajax.
I have the following script that displays a modal login form after cliking on login_link.
But for my web page, i used the .load to load content in the main content div, so whenever this code is placed the the document.ready, the modal form dont wont, but if i comment it, it works fine, please help, tkx
here is the code

img2 = new Image(220, 19);  

// When DOM is ready


// Launch MODAL BOX if the Login Link is clicked

// When the form is submitted
$("#status > form").submit(function(){  

// Hide 'Submit' Button

// Show Gif Spinning Rotator

// 'this' refers to the current submitted form  
var str = $(this).serialize();  

// -- Start AJAX Call --

    type: "POST",
    url: "do-login.php",  // Send the login info to this page
    data: str,  
    success: function(msg){  

$("#status").ajaxComplete(function(event, request, settings){  

 // Show 'Submit' Button

// Hide Gif Spinning Rotator

 if(msg == 'OK') // LOGIN OK?
 var login_response = '<div id="logged_in">' +
     '<div style="width: 350px; float: left; margin-left: 70px;">' + 
     '<div style="width: 40px; float: left;">' +
     '<img style="margin: 10px 0px 10px 0px;" align="absmiddle" src="images/ajax-loader.gif">' +
     '</div>' +
     '<div style="margin: 10px 0px 0px 10px; float: right; width: 300px;">'+ 
     "You are successfully logged in! <br /> Please wait while you're redirected...</div></div>";  



 $(this).html(login_response); // Refers to 'status'

// After 3 seconds redirect the 
setTimeout('go_to_private_page()', 3000); 
 else // ERROR?
 var login_response = msg;




// -- End AJAX Call --

return false;

}); // end submit event


function go_to_private_page()
window.location = 'private.php'; // Members Area

Recommended Answers

All 3 Replies

If you're loading the page content with AJAX, then the problem might be that the element to which the click event is applied on line #11 no longer exists (i.e. it has been replaced when the page content loaded).

Try using the live function to bind click events to all current and future DOM elements with the id login_link. To do this change line #11 to:
$("#login_link").live('click', function() {

its still the same dude

Unlucky. Post your HTML.

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.