Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7173221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:46:44+00:00 2026-05-28T15:46:44+00:00

I have html elements with class ajaxem that are ment to be used in

  • 0

I have html elements with class “ajaxem” that are ment to be used in my jquery below. I also have the same for any form elements. For the first few ajax requests the jquery is attached and triggered and work properly. However, after a user logs in or registers, the returned links (which also have class=”ajaxem”) are not caught by jquery and not triggered.

I have tried all three implementations. and also tried to reapply them AFTER each ajax request. but none have worked.

<script type="text/javascript">
function updateajaxem() {


    $(document).on("click", "a.ajaxem", function (e) {
        e.preventDefault();

        var action = $(this).attr('href');
        //alert(action);
        if (action.indexOf('register') > 0) {

            $("div#logininfo").load("http://localhost/testrun/auth/register/").fadeIn();

        } else if (action.indexOf('password') > 0) {
            $("div#logininfo").load("http://localhost/testrun/auth/forgot_password/").fadeIn();

        }

    }); //end 
}
</script>
<script type="text/javascript">
 updateajaxem();

//$("a.ajaxem").live("click", function(e){ 

$(document).on("click", "input:submit", function (e) {
    e.preventDefault();

    var formaction = $(this).closest('form').attr('action');
    var dataString = $(this).closest('form').serialize();
    alert(dataString);
    //$("div#logininfo").load(formaction,data);
    $.ajax({
        type: "POST",
        url: formaction,
        data: dataString,
        //   dataType: "json",
        success: function (data) {
            alert(data);

            $("div#logininfo").html(data);
            updateajaxem();


        } // end of success
    });





});
</script>

the outputted html at which the scripts stop working is below:

<div id="container">
    <h1>Welcome to CodeIgniter!</h1>
<a href="auth/logout/">Logout</a> <a href="">Home</a>
    <div id="body">
        <p>The page you are looking at is being generated dynamically by CodeIgniter.</p>

        <p>If you would like to edit this page you'll find it located at:</p>
        <code>application/views/welcome_message.php</code>

        <p>The corresponding controller for this page is found at:</p>
        <code>application/controllers/welcome.php</code>

        <p>If you are exploring CodeIgniter for the very first time, you should start by reading the <a href="user_guide/">User Guide</a>.</p>
    </div>

    <p class="footer">Page rendered in <strong>1.0343</strong> seconds</p>
    <div id="logininfo">You have successfully registered. <a href="http://localhost/testrun/auth/login" class="ajaxem">Login</a></div>
</div>

which makes no sense since it includes the class “ajaxem” which should be caught by jquery but is not.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T15:46:45+00:00Added an answer on May 28, 2026 at 3:46 pm

    Since the returned link’s href does not contain the words ‘register’ or ‘password’ neither of the following conditions are met:

    if (action.indexOf('register') > 0) {
        $("div#logininfo").load("http://localhost/testrun/auth/register/").fadeIn();
    } else if (action.indexOf('password') > 0) {
       $("div#logininfo").load("http://localhost/testrun/auth/forgot_password/").fadeIn();
    }
    

    so no ajax request happens.

    You will probably need to account for the ‘login’ scenario, e.g.:

    } else if (action.indexOf('login') > 0) {
       $("div#logininfo").load("http://localhost/testrun/auth/login/").fadeIn();
    }
    

    …and why hard-code the URLs when they can be extracted from the clicked anchor?

    if (action.indexOf('register') > 0) {
        $("div#logininfo").load(this.href).fadeIn();
    } else if (action.indexOf('password') > 0) {
       $("div#logininfo").load(this.href).fadeIn();
    } else if (action.indexOf('login') > 0) {
       $("div#logininfo").load(this.href).fadeIn();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that generates some html (form elements and table elements), but
I want to add some HTML elements that have the same class name. So,
I have some JQuery code that converts all HTML elements of a specific class
I've got several elements on a HTML page which have the same class -
I have 2 HTML elements that are of the same type. One element has
i have several common elements (components), that will generate some html. it seems my
I have a simple MVC form with the following elements: <%= Html.TextBox(FechaInicio) %> Which
I have the html below: <span class=srch-URL> <a id=CSR_U_2 href=http://www.test.com/TestForm.aspx>http://www.test.com/TestForm.aspx</a> </span> I am trying
Suppose I have the following HTML: <div class=container> <span class=remove>remove</span> </div> and jquery: $(.container).delegate(.remove,
I have some HTML code that contains nested <ul> elements and I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.