Home  >  Article  >  Web Front-end  >  jquery捕捉回车键及获取checkbox值与异步请求的方法_jquery

jquery捕捉回车键及获取checkbox值与异步请求的方法_jquery

WBOY
WBOYOriginal
2016-05-16 15:23:521318browse

本文实例讲述了jquery捕捉回车键及获取checkbox值与异步请求的方法。分享给大家供大家参考,具体如下:

1、jquery捕捉回车键:

$("html").die().live("keydown",function(event){
  if(event.keyCode==13){
   //这里添加要处理的逻辑
  }
});

2.jquery获得多个选中的checkbox值:

$('input[type="checkbox"][name="types"]:checked').each(function() {
  types = types+$(this).val()+ "|";
 }
);

3.jquery异步请求的方法:

$.ajax({
  url : "${pageContext.request.contextPath}/UOSRoleManangerAction.do?method=createRole",
  type : "post",
  dataType : "html",
  data:{"roleName":roleName,"roleDescription":roleDescription,"roles":roles,"types":types},
  success : function(data){
   var dataObj=eval("("+data+")");
   if(dataObj.result){
    alert("操作成功!");
    submitForm(null,"initPage");
   }else {
    alert("操作失败!");
   }
  }
});

希望本文所述对大家jQuery程序设计有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn