Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
更改jQuery帖子的类型_Jquery_Html_Ajax_Function_Post - Fatal编程技术网

更改jQuery帖子的类型

更改jQuery帖子的类型,jquery,html,ajax,function,post,Jquery,Html,Ajax,Function,Post,如何将此函数更改为$.post函数,保留所有按钮属性等。 我需要将num的值发送到javas.php,然后在status类中回显该数据。这是否可行: $(".eventer button[name=lol]").click(function() { console.log('clicked'); thisBtn = $(this); parent = $(this).parent(); num = parent.data('num'); id = parent.data('id');

如何将此函数更改为$.post函数,保留所有按钮属性等。 我需要将num的值发送到javas.php,然后在status类中回显该数据。

这是否可行:

$(".eventer button[name=lol]").click(function() { 
console.log('clicked'); 
thisBtn = $(this); 
parent = $(this).parent(); 
num = parent.data('num'); 
id = parent.data('id'); 

if(typeof num != 'number'){ 
    num = 0; 
} 
$(this).attr('disabled', true); 

$.ajax({ 
    url: 'javas.php', 
    data: "num="+ ( num + 1 ) +"&id="+id, 
    success: function(data) {
        console.log('Ajax success'); 
        parent.data('num', ++num); 
        parent.next('.status').html(num); 
        thisBtn.attr('disabled', false); // reset 
    } 
}); 

console.log('-- end'); 
 }); 
见:

 $.post('javas.php', {num: (num+1), id: id}, function(data) { ... });