Click here to Skip to main content
15,121,564 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
i use java script for insert to db
but dont work
my code :
function InsertComment(id) {

$.ajax({
url: "/tickets/AddComment/" + id,
type: "GET",
data: { text: $("#txtName").val() }
}).done(function () {
//here put a code for done method
});

}

What I have tried:

i trace with firebug and see id have value but text is null
#textname is id for input
Posted
Updated 17-Apr-17 1:26am

1 solution

Just make sure you use the correct ID for the element, because that matters, you mention in your "What I have tried:" section,
Quote:
#textname is id for input
So, in that case the code would be like the following,
JavaScript
function InsertComment(id) {
   $.ajax({
      url: "/tickets/AddComment/" + id,
      type: "GET",
      data: { 
          text: $("#textname").val() // Notice the change here.
      }
   }).done(function () {
      //here put a code for done method
   });
}

If this element is found, and returns a value, then you will get the text parameter filled in the query string as well.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900