Post data ajax to php

Post data ajax to php

本文关键字:php to ajax data Post      更新时间:2023-09-26

我想张贴的值,当一些点击删除。请检查错误

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

我不知道如何将值传递给checkkid变量

我认为你的代码应该是这样的:

$('#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 );
       }); 
 });

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 );
       });
});

从$。Ajax函数,当您需要在按钮上触发post事件时单击

您需要使用的正确代码:

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