Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/434.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/jquery/85.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
Javascript 仅在IOS中不更新Ajax表单_Javascript_Jquery - Fatal编程技术网

Javascript 仅在IOS中不更新Ajax表单

Javascript 仅在IOS中不更新Ajax表单,javascript,jquery,Javascript,Jquery,我有一个ajax表单,可以用来编辑表行。一旦提交表单并收到响应,表中的值就会更新。它在chrome中运行得很好,但由于某些原因,这些值在IOS中不会更新(除非我刷新页面)。 我在StackOverflow上读到,您需要向代码中添加cache:false,但问题仍然存在。你知道我做错了什么吗 $(document).on("click", ".myBtn", function(){ var id = $(this).attr("data-id") var form = $(

我有一个ajax表单,可以用来编辑表行。一旦提交表单并收到响应,表中的值就会更新。它在chrome中运行得很好,但由于某些原因,这些值在IOS中不会更新(除非我刷新页面)。 我在StackOverflow上读到,您需要向代码中添加
cache:false
,但问题仍然存在。你知道我做错了什么吗

$(document).on("click", ".myBtn", function(){
      var id = $(this).attr("data-id")
      var form = $("#edit_newcredit");

 $.ajax( {
      type: "POST",
      url: form.attr( 'action'),
      data: form.serialize(),
      dataType : "html",
      contentType: "application/x-www-form-urlencoded; charset=UTF-8",
      cache: false,
      headers: { "cache-control": "no-cache" },
      success: function( response ) {
        console.log( response );

      $("#"+id).closest('tr').next('tr').remove(); //Remove the next tr
      $("#"+id).closest('tr').replaceWith(response); //Replace the current tr

      },        
  });
});

如果在刷新后看到更新,则表示
POST
成功。我猜这可能与您的连接有关,以确定id。请确保设置了
id
的值。尝试
varid=$(this.data(“id”)
用于设置变量。对于POST请求,您不需要
cache:false
,它们永远不会被缓存。您不需要
contentType
选项,这是默认选项。感谢您的帮助。很好的建议,因为我现在可以看到,IOS上没有定义var id。与我在移动视图中显示的行有关。非常有用。