我的ajax代码
$(document).ready(function() {
$("#sub").click(function() {
$.ajax({
type: "POST",
url: "jqueryphp.php",
data: "txt1=" + txt1,
success: function(result) {
$("div").html(result);
}
});
});
});?
Run Code Online (Sandbox Code Playgroud)
这是表单代码.我想将txt1值传递给ajax
<input type="text" name="txt1" id="txt1" /><br>
<input type="button" name="sub" id="sub" value="click Me" />
Run Code Online (Sandbox Code Playgroud)
我想使用这个ajax函数将txt1值传递给我的php页面.请告诉我.ajax的数据属性会有什么意义