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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:04:19+00:00 2026-05-22T15:04:19+00:00

In the below code, after success need to bind the click and should fire

  • 0

In the below code, after success need to bind the click and should fire the event in the first click only.

$(this).click(function(){
   var $obj = $(this);
   var urlLink = someURL;
   var data = "id=" + "123";
   $.ajax({
        url : urlLink,
    data : data,
    cache: false,
    success : function(resp) {
      $obj.bind("click",eval(someFunction)); //This someFunction will call another function.
    }
   });
});

Please let me know how to fire two events like this in one click.
Right now, to execute i need to click twice.

Thanks in advance…

  • 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-22T15:04:20+00:00Added an answer on May 22, 2026 at 3:04 pm

    Your code is failing before the trigger, because the variable event is not defined, your function crashes at the line event.stopPropagation(). Also, try to get rid of eval in the event binding, what exactly is TRTP.showSourceToolTip?

    If it’s a function, you can just do the following:

    success : function(resp) {
        // Bind the click event to a function
        $obj.click(TRTP.showSourceToolTip);
    
        // This will call the function in the context of the object's DOM element
        TRTP.showSourceToolTip.apply($obj[0]);
    }
    

    Update:

    The problem with the updated code is that you will just keep binding click events. If you bind and event in jQuery, it won’t replace the original, but both actions will fire in order. You might want to unbind() your ajax handler once there is a proper response.

    The code below will actually unbind the ajax handler right after the request will fire to avoid repeated clicks before the response. Once the ajax is successful, it will bind a different handler, and triggers its click. If the ajax fails, it will bind the ajax handler back so the user can try again.

    function ajaxHandler(){
        var $obj = $(this);
        var urlLink = someURL;
        var data = "id=" + "123";
    
        // Unbind the ajax handler to prevent re-fire before ajax request completes
        $obj.unbind("click", ajaxHandler);
    
        $.ajax({
            url: urlLink,
            data: data,
            cache: false,
            success: function(resp){
                // Bind the new event handler
                // Removed eval from the bind, put it back if you desperately need it
                $obj.bind("click", someFunction);
    
                // Fire click on Object
                $obj.click();
            },
            error: function(){
                // Put the ajax handler back so the user can try again if it fails
                $obj.bind("click", ajaxHandler);
            }
        });
    }
    
    // This is where you first bind the ajax handler
    // I'm not sure what scope you're in, make sure this references the desired object.
    $(this).click(ajaxHandler);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code below. I expected after submitting the form it goes to
In the below code sample, what does {0:X2} mean? This is from the reflection
When retrieving objects from an NSMutableArray in cocoa-touch is the below code ok? Should
In my code i need to poll a url after every 5 seconds using
In the code below the Save button click is not firing. Any ideas why?
The below code makes application freeze when changing focus from Edit1 to Edit2 after
I have the below code on the KeyPress event of a textbox howver a
When running the below code a type is never returned, despite there being a
In the below code snippet can i replace char * to const char *
I have the below code in stdafx.h. using namespace std; typedef struct { DWORD

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.