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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:24:29+00:00 2026-05-22T16:24:29+00:00

The following is my generated html code. I’m having a bit of trouble coming

  • 0

The following is my generated html code. I’m having a bit of trouble coming up with what should be the jquery code to fire an ajax request upon a user clicking the activate button.

<span class="vId">
    <input type="hidden" name="id" id="7" />
    <input type="hidden" name="ClientID" id="026CC6D7-34B2-33D5-B551-CA31EB6CE345" />
    <input class="textbox" type="text"   name="key" />
    <input class="button"  type="button" name="Activate" value="Activate" />
</span>
<span class="gc_Name">Bartlett-White</span>             
<span class="vId">
    <input type="hidden" name="id" id="2" />
    <input type="hidden" name="ClientID" id="000214EE-0000-0000-C000-000000000046" />
    <input class="textbox" type="text" name="key" />
    <input class="button" type="button" name="Activate" value="Activate" />
</span>
<span class="gc_Name">Landingham Bends</span>             
<span class="vId">
    <input type="hidden" name="id" id="8" />
    <input type="hidden" name="ClientID" id="049F2CE6-D996-4721-897A-DB15CE9EB73D" />
    <input class="textbox" type="text" name="key" />
    <input class="button" type="button" name="Activate" value="Activate" />
</span>
<span class="gc_Name">Russell River</span>             

My idea, is as follows:

<script type="text/javascript">
$().ready(function(){
    $.each($(".button")
      .click(function() {
            $.ajax({
                url:  '{site_url}index.php/activate',
                type: 'POST', 
                dataType: 'html',
                data: {
                    key: $(this).sibling(':first'),
                    idclient: $(this).sibling(':first:next'),
                },
                success: function(result) {

                }
            });
        });
    )
});
</script>

While I know my jquery doesn’t work, I’m a bit stumped…any help would be greatly appreciated. As i said, I’m attempting to send an ajax request off to the activate controller whenever a user clicks the activate button, however I also need to send the hidden data within the same span as well.

Once again thanks for any help.

  • 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-22T16:24:29+00:00Added an answer on May 22, 2026 at 4:24 pm
    $(".button").click(function(e) {
        e.preventDefault();
        var that = this;
        $.ajax({
            url: '{site_url}index.php/activate',
            type: 'POST',
            dataType: 'html',
            data: {
                key: $(that).prev().attr('id'),
                idclient: $(that).siblings('[name="clientID"]').attr('id'),
            },
            success: function(result) {
                alert(result);
                $(that).blahblah();
            }
        });
    });
    
    1. There is no need to loop over the buttons. $(".button").click(... will implicitly attach a handler to all elements with the ‘button’ class.
    2. You need to assign the context to a variable in order that it is accessible within the callbacks/scope of the $.ajax call.
    3. Ideally you should prevent form submission by making use of event.preventDefault()
    4. Your traversing is incorrect, and there is no :next pseudo-selector as far as I know.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following html generated through my PHP code. What I want to
I have the following HTML generated by an ASP.NET repeater: <table> <tr> <td><input type=hidden
I have the following html structure (which is generated and I can't change): <table
Take the following JSON string (generated by some ExtJS code - but that's irrelevant):
I'm confused about the errors generated by the following code . In Derived::doStuff, I
How can I make sure the CS generated from code like the following is
I have the following razor code: <form id=logon action=/security/dev method=get> @Html.AntiForgeryToken() @Html.EditorFor(x => x.UserName)
Let me brief you the whole requirement first. I have the following HTML code:
I have following generated code and tried to retrive the radio button value or
I have the following html code: <div id=result1 class=result> ... some html ... ...

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.