Pra*_*k M 0 javascript php parameters ajax jquery
我的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的数据属性会有什么意义
man*_*ire 15
将数据作为对象而不是字符串发送并检索文本字段的值,请使用val():
$(document).ready(function() {
$("#sub").click(function() {
$.ajax({
type: "POST",
url: "jqueryphp.php",
data: {
txt1: $("#txt1").val()
},
success: function(result) {
$("div").html(result);
}
});
});
});?
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
31825 次 |
| 最近记录: |