0

I want to post the value when some click on delete. Please check the error

$.ajax({
         type: "POST",
         var checkid =  $('#delete').click(function(){ $(this).val();});,
         url: "survey-command.php",
         data: { checkid: checkid, }
            }).done(function( msg ) {
                alert( "Data Saved: " + msg );
       });  

I dont know how pass the value to this checkid variable

1
  • So whats the problem? why do you think it isn't working? Commented Aug 23, 2014 at 12:54

3 Answers 3

1

Your code I believe should look like this:

$('#delete').click(function(){
   var checkid= $(this).val(); //assuming $('#delete') is an input.
                               // otherwise use $('#delete').html();
    $.ajax({
         type: "POST",
         url: "survey-command.php",
         data: { checkid: checkid, }
            }).done(function( msg ) {
                alert( "Data Saved: " + msg );
       }); 
 });
Sign up to request clarification or add additional context in comments.

Comments

0

Use This

$('#delete').click(function(){ 
var checkid = $(this).val();
$.ajax({
         type: "POST",         
         url: "survey-command.php",
         data: { checkid: checkid, }
            }).done(function( msg ) {
                alert( "Data Saved: " + msg );
       });
});

Remove the Click from the $.ajax function as you need to fire the post event on the button click

Comments

0

This the correct code that you need to use :

     $('#delete').click(function(){     
       $.ajax({
         type: "POST",
         url: "survey-command.php",
         data: { checkid: $(this).val();, }
            }).success(function( msg ) {
                alert( "Data Saved: " + msg );
        });
   }); 

2 Comments

ha ha ha ha Levuva Patel
Gr8, can we move this conversation to whats app ? ;-)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.