Home >Web Front-end >JS Tutorial >jquery's method of capturing the enter key and getting the checkbox value and asynchronous request_jquery

jquery's method of capturing the enter key and getting the checkbox value and asynchronous request_jquery

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

The example in this article describes how jquery captures the enter key and obtains the checkbox value and asynchronous requests. Share it with everyone for your reference, the details are as follows:

1. jquery captures the Enter key:

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

2.jquery gets multiple selected checkbox values:

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

3.jquery asynchronous request method:

$.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("操作失败!");
   }
  }
});

I hope this article will be helpful to everyone in jQuery programming.

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