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

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

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

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

1、jquery捕捉回车键:

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

Copy after login

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

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

Copy after login

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

Copy after login

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

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!