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 6658849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:57:42+00:00 2026-05-26T01:57:42+00:00

I have a page on my site that uses jquery. In the jquery script

  • 0

I have a page on my site that uses jquery. In the jquery script there are onclick events using css classes, also I use a jquery ajax call to get data from my database and then return the results and load the results via ajax on my page on the site. Within the results returned by the ajax call are the css classes that have the onclick event setup in my jquery script. My issue is none of the onclick events work when I return the results via ajax, if I dont use ajax and just load the results via the page itself then the onclick events work. Is there a way to have the jquery onclick events work inside data returned by an ajax call?

$('#myformsubmit').click(function(){
    var dataString = $('#myform').serialize();
    $.ajax({
        type:"POST",
        url:"/ajax/formaction/process.php",
        data:dataString,
        success: function(data) {
            var formdata = $.parseJSON(data);

            $('#myformsg').html(formdata.formmsg);
            $('html, body').animate({ scrollTop:0 }, '1000');

            if(formdata.status == 'success')
            {

                $('#myform')[0].reset();

            }
        }
    });
    return false;
});

Then I have this code for the click event:

$('.selectoption').click(function(){
    var optionurl = $(this).attr('alt');
    window.location = '/option/view/' + optionurl;
    return false;
});

Inside the results from the ajax call the selectoption class is associated with a button, when I click it nothing happens. When I load the results via the page directly it works just fine. Any suggestions?

  • 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-26T01:57:42+00:00Added an answer on May 26, 2026 at 1:57 am

    I’m not totally clear about what you’re doing, but you could try using ‘live‘ –

    $('.selectoption').live('click',function(){
        var optionurl = $(this).attr('alt');
        window.location = '/option/view/' + optionurl;
        return false;
    });
    

    That will assign the click event to all the ‘.selectoption’ classes including those that are created dynamically.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web site in asp.net that uses a master page. In this
I have an ssl page that also downloads an avatar from a non-ssl site.
I have an ASP.NET site that uses JQuery and ASP.NET UpdatePanel and ScriptManager. On
I have a page that uses JQuery UI; in particular the Sortable interaction. The
I have a page with a menu that uses JQuery AJAX calls to populate
I have a page that uses jQuery's $.post() method to get some html and
I have a site that uses the jQuery jEditable plugin (inline editing via AJAX).
Here's my conundrum: I have a page that uses Google Maps V3 and jQuery.
I have a site that is using jQuery UI to display forms located on
I have a site that uses the default SqlMembershipProvider and FormsAuthentication. I can use

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.