
ajax调用后台方法主要使用到url,返回值用data接受,success中回显到前台,例如我用maven搭建的springMVC项目中
1ajax的请求
2传到后台的值
3传回来的值,dataType是返回来的类型
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 401 Transitional//EN">
<html>
<head>
<title>checkbox</title>
<script src="js/jquery-132js" type="text/javascript"></script>
<script src="js/1js" type="text/javascript"></script>
</head>
<body>
<table id="table1">
<tr>
<td><input type="checkbox" value="1"/>1</td>
<td id="k_1"><input type="text" name="student" id="s_1" readonly="true"/></td>
</tr>
<tr>
<td><input type="checkbox" value="2"/>2</td>
<td id="k_2"><input type="text" name="student" id="s_2" readonly="true"/></td>
</tr>
<tr>
<td><input type="checkbox" value="3"/>3</td>
<td id="k_3"><input type="text" name="student" id="s_3" readonly="true"/></td>
</tr>
<tr>
<td><input type="checkbox" value="4"/>4</td>
<td id="k_4"><input type="text" name="student" id="s_4" readonly="true"/></td>
</tr>
</table>
</body>
</html>
-------------------------------------------------------------
$(document)ready(function() {
$("td[id^='k_']")hide();
var check = $(":checkbox"); //得到所有被选中的checkbox
var actor_config; //定义变量
checkeach(function(i){
actor_config = $(this);
actor_configclick(
function(){
if($(this)attr("checked")==true){
$("#k_"+$(this)val())show();
}else{
$("#k_"+$(this)val())hide();
}
}
);
});
});
问题:
1少了参数data:
2选择器没有写好,少了一个点;
$("title a")click(function()
{
alert('110');
})
3例子:
$(function(){
$('#send')click(function(){
$ajax({
type: "GET",
url: "testjson",
data: {username:$("#username")val(), content:$("#content")val()},
dataType: "json",
success: function(data){
$('#resText')html(html);
}
});
});
});
4对照一下,少哪些参数加上去即可
以上就是关于Ajax怎么调用后台方法,且获取该方法的返回值全部的内容,包括:Ajax怎么调用后台方法,且获取该方法的返回值、jquery ajax获取返回值为null、js中获取ajax返回的值等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)