ajax回调有参的函数

前端之家收集整理的这篇文章主要介绍了ajax回调有参的函数前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
搞52lz会员管理,跟进记录提交成功后刷新某个div,我写成:
<form action="/weihu/site/coinsmgr/addviplog.xhtml" class="pageForm required-validate" onsubmit="return validateCallback(this,refreshFollowLogs(${info.loginType},${info.userId}));" method="post">

结果先执行refreshFollowLogs,然后再执行action,因为refreshFollowLogs()就是一个执行结果。所以改成

<form action="/weihu/site/coinsmgr/addviplog.xhtml" class="pageForm required-validate" onsubmit="return validateCallback(this,refreshFollowLogs);" method="post">



就OK了,但我要传递的参数怎么办?
1.搞成全局变量
2.把onsubmit="return validateCallback(this,refreshFollowLogs);"里的 refreshFollowLogs改成匿名函数
3.把参数写到 refreshFollowLogs函数里。
我用第三种:
function refreshFollowLogs(){
	var lType=${info.loginType},uId=${info.userId}
	$("#table-vipLogs").ajaxUrl({
		type:"GET",url:"/weihu/site/coinsmgr/vip/loglist.xhtml?loginType="+lType+"&userId="+uId,callback:function(){
			//$("#infoAdminSearch0-BoxId").find("[layoutH]").layoutH();
		}
	});
	return false;
}
原文链接:https://www.f2er.com/ajax/163426.html

猜你在找的Ajax相关文章