JavaScript how can i send dynamically appended value to controller

<form id="participantsForGd">
<span id="GroupID"></span> //in here group id is coming example: 2
<button id="GdStartTest">Start test</button>
</form>

I want to send the value of GroupID to the controller using Ajax call how can i do that.? this is my append java script..

$("#GroupID").append( group ); //in here Example: group value=2

This my controller page call:

$("#GdStartTest").click(function(){
    $.ajax({
data: {Gd: $("#participantsForGd").serialize(), 'action': 'startGdstudents', },

I want to add that group id in Ajax data: or input type=hidden form.. how can i do that

Answer:1
$("#GdStartTest").click(function(){
    $.ajax({
data: {Gd: "sometext-"+ $("#GroupID").text(), 'action': 'startGdstudents', }

".text()" : will return you the content of the element.

if you want to create hidden input you can do it like:

$("#groupID").val(); // this will return you the value

$("#GdStartTest").click(function(){
        $.ajax({
    data: {Gd: "sometext-"+ $("#GroupID").val(), 'action': 'startGdstudents', }
Answer:2

put a hidden input in the form also and it would be included in serialize()

<form id="participantsForGd">
    <input type="hidden" value="2" name="GroupID">
    <span id="GroupID"></span> //in here group id is coming example: 2
    <input type="submit" id="GdStartTest">Start test</button>
</form>
Answer:3

I want to find last descendent div of the html below. I tried but it finds the first occurrence of the div. How can I achieve this? HTML: <div class='greatparent'> <div> <div&...

I want to find last descendent div of the html below. I tried but it finds the first occurrence of the div. How can I achieve this? HTML: <div class='greatparent'> <div> <div&...

I am trying to take what a user enters in a textbox, and then write that input to a paragraph on the page, and stop the page refreshing so that they can then copy that input for use elsewhere. (it'...

I am trying to take what a user enters in a textbox, and then write that input to a paragraph on the page, and stop the page refreshing so that they can then copy that input for use elsewhere. (it'...

  1. html javascript display none
  2. html javascript display text
  3. html javascript display
  4. html javascript display all images in a folder
  5. html javascript display image
  6. html javascript display variable
  7. html javascript display date and time
  8. html javascript display block
  9. html javascript display json
  10. html javascript display running time
  11. html javascript display pdf
  12. html javascript display message
  13. html javascript display current time
  14. html javascript display current date
  15. html javascript display date
  16. html javascript display array
  17. html display javascript object
  18. html display javascript function output
  19. html display javascript variable value
  20. html display javascript return value

By using JavaScript or jQuery, I am trying to figure out if a word, say "casablanca", is available on the page? The page I am working on makes an ajax call which changes the content of the page. So I ...

By using JavaScript or jQuery, I am trying to figure out if a word, say "casablanca", is available on the page? The page I am working on makes an ajax call which changes the content of the page. So I ...

  1. searching word on web page

This my code when click the button i want to display button dynamic id to the specific place by calling that id: this is my code: <span id="2" class="view-details">View Details</span> $( ...

This my code when click the button i want to display button dynamic id to the specific place by calling that id: this is my code: <span id="2" class="view-details">View Details</span> $( ...

  1. jquery append not working with html