0

我有一个非常简单的 html 页面,其中包含一个表单和几个控件。此 html 页面托管在服务器上。当我在输入字段中发布带有某些值的表单时,它不会在表单发布数据中显示输入值。

reuest body 只有 btn1=post 其他控件没有列出

下面是html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>test</title>
</head>
<body>    
    <form id="form4" action="somePage.htm" method="post" >
    <input type="text" id="textMain1" value="" />
    <input type="text" id="textMain2" value=""/>
    <input type="text" id="textMain3" value=""/>

    <input type="submit" id="btn1" name="btn1"  />
    </form>
</body>
</html>![enter image description here][2]

这些我已经尝试过: - 将名称和 id 属性一起添加到输入控件 - 添加 runat=server 以防万一(html页面是在 VS IDE 中编写的) - 添加 enctype="multipart/form-data" 以形成 - 运行它铬浏览器

4

1 回答 1

0

可能此链接已定义您想要的内容并对您有用

$("#form4").submit(function(event) {

/* stop form from submitting normally */
event.preventDefault();

/* get some values from elements on the page: */
 var values = $(this).serialize();

/* Send the data using post and put the results in a div */
$.ajax({
  url: "test.php",
  type: "post",
  data: values,
  success: function(){

  },

  }); 
});
于 2013-04-05T05:29:09.463 回答