我建议使用ajax()
像这样的东西:
$.ajax({
  type: "POST",
  url: "post.asp",
  data: { update2: firstname } //you can add more values in here if you need
  }).done(function( msg ) {
  alert( "Data Saved: " + msg );
});
Done 将在 ajax() 调用完成时触发。
如果您需要检查此代码是否按您的意愿完成,那么您可以使用以下内容:
$.ajax({
      type: "POST",
      url: "post.asp",
      data: { update2: firstname }, //you can add more values in here if you need
      cache: false,
      success: function(response)
      {alert(response);}                                               
       }).done(function( msg ) {
      alert( "Data Saved: " + msg );
    });
编辑:
如果您只想发布,那么您可以使用以下内容:
$.post("test.php", { name: "John", time: "2pm" }).done(function(data) {  alert("Data loaded: " + data);});