Home > Web Front-end > JS Tutorial > body text

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

WBOY
Release: 2016-05-16 15:23:52
Original
1354 people have browsed it

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){
   //这里添加要处理的逻辑
  }
});

Copy after login

2.jquery gets multiple selected checkbox values:

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

Copy after login

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

Copy after login

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

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template