1. $(".login_btn").click(function(){
  2.  
  3. if($(".user_").val()=="admin"&&($(".password_").val()=="123456")){
    var data = {
    user: "admin",
    password:"123456"
    }
    $.ajax({
    cache: false,
    type:"post",
    url: com.webappRootPath + "/main",
    timeout: 10000,
    async: true,
    data:data,
    dataType:"json",
    //beforeSend:loading,
    error: function (request) {
    // loading_none();
    alert("cuo le !");
    },
    success: function (data) {
    console.info(data)
  4.  
  5. if (data['user']!=null) {
    window.location.href = com.webappRootPath + "/main1";
  6.  
  7. }
    }
    });
  8.  
  9. // window.location.href = com.webappRootPath + "/main?user=admin";
    // var temp = document.createElement("form");
    // temp.action =com.webappRootPath + "/main" ;
    // temp.method = "post";
    // temp.style.display = "none";
    //
    // var opt = document.createElement("textarea");
    // opt.name = "user";
    // opt.value = "admin";
    // // alert(opt.name)
    // temp.appendChild(opt);
    //
    // document.body.appendChild(temp);
    // temp.submit();
    // post('/main', {user :"admin"});
  10.  
  11. }else if($(".user_").val()=="jinqiao"&&($(".password_").val()=="123456")){
    //window.location.href = com.webappRootPath + "/main?user=jinqiao";
    var data2 = {
    user: "jinqiao",
    password:"123456"
    }
    $.ajax({
    cache: false,
    type:"post",
    url: com.webappRootPath + "/main",
    timeout: 10000,
    async: true,
    data:data2,
    dataType:"json",
    //beforeSend:loading,
    error: function (request) {
    // loading_none();
    alert("chu cuo le !");
    },
    success: function (data) {
    console.info(data)
  12.  
  13. if (data['user']!=null) {
    window.location.href = com.webappRootPath + "/main2";
  14.  
  15. }
    }
    });
  16.  
  17. } else {
    $(".error_").slideDown();
    var timer=setTimeout(function(){
    $(".error_").slideUp();
    },2000)
    }
    });
    function post(url, params) {
    var temp = document.createElement("form");
    temp.action = url;
    temp.method = "post";
    temp.style.display = "none";
    for (var x in params) {
    var opt = document.createElement("input");
    opt.name = x;
    opt.value = params[x];
    temp.appendChild(opt);
    }
    document.body.appendChild(temp);
    temp.submit();
    return temp;
    }
  18.  
  19. $(document).keyup(function(e){
    if(e.keyCode == 13){
    if($(".user_").val()=="admin"&&($(".password_").val()=="123456")){
    // window.location.href = com.webappRootPath + "/main?user=admin";
    $.ajax({
    cache: false,
    type:"post",
    url: com.webappRootPath + "/main",
    timeout: 10000,
    async: true,
    dataType:"text",
    //beforeSend:loading,
    error: function (request) {
    // loading_none();
    alert("连接超时!");
    },
    success: function (data) {
    alert(data);
    if (data == "success") {
    window.location.href = com.webappRootPath + "/main1";
  20.  
  21. }
    }
    });
    }else if($(".user_").val()=="jinqiao"&&($(".password_").val()=="123456")){
    //window.location.href = com.webappRootPath + "/main?user=jinqiao";
    var data2 = {
    user: "jinqiao",
    password:"123456"
    }
    $.ajax({
    cache: false,
    type:"post",
    url: com.webappRootPath + "/main",
    timeout: 10000,
    async: true,
    data:data2,
    dataType:"json",
    //beforeSend:loading,
    error: function (request) {
    // loading_none();
    alert("chu cuo le !");
    },
    success: function (data) {
    console.info(data)
  22.  
  23. if (data['user']!=null) {
    window.location.href = com.webappRootPath + "/main2";
  24.  
  25. }
    }
    });
  26.  
  27. } else {
    $(".error_").slideDown();
    var timer=setTimeout(function(){
    $(".error_").slideUp();
    },2000)
    }
    }
    });
    //var cj_length=$(".cj_").length;
    //for(var i=0;i<cj_length;i++){
    $(".cj_").hover(function(){
    $(this).find(".img1").css("display","none");
    $(this).find(".img2").css("display","block");
    $(this).find(".cj_word").css("color","#6c8ebe");
    },function(){
    $(this).find(".img1").css("display","block");
    $(this).find(".img2").css("display","none");
    $(this).find(".cj_word").css("color","#333");
    });
  28.  
  29. $("#input-ficons-1,#input-ficons-2").fileinput({
    uploadUrl: "/file-upload-batch/2",
    uploadAsync: true,
    previewFileIcon: '<i class="fa fa-file"></i>',
    allowedPreviewTypes: null, // set to empty, null or false to disable preview for all types
    previewFileIconSettings: {
    'docx': '<i class="fa fa-file-word-o text-primary"></i>',
    'xlsx': '<i class="fa fa-file-excel-o text-success"></i>',
    'pptx': '<i class="fa fa-file-powerpoint-o text-danger"></i>',
    'jpg': '<i class="fa fa-file-photo-o text-warning"></i>',
    'pdf': '<i class="fa fa-file-pdf-o text-danger"></i>',
    'zip': '<i class="fa fa-file-archive-o text-muted"></i>',
    }
    });
    /**
    * 点击左侧菜单事件
    * */
    function toMenu(url,methord,callback,params) {
  30.  
  31. if(url=="fund"){
    callback = "fundInit";
    }
  32.  
  33. if(url=="order"){
    callback = "orderInit";
    }
  34.  
  35. methord = "POST";
    if(!methord){
    methord = "GET";
    }
  36.  
  37. if(!params){
    params="";
    }
    console.info(url);
    $("#main").html("");
    $.ajax({
    cache: false,
    type: methord,
    url: com.webappRootPath+"/"+ url+"?"+encodeURI(encodeURI(params)),
    timeout: 10000,
    async: true,
    //beforeSend:loading,
    error: function (request) {
    // loading_none();
    alert("连接超时!");
    },
    success: function (data) {
    $("#main").html(data);
    if(callback && callback != ''){
    var func=eval(callback);
    new func();
    }
    //loading_none();
    }
    });
    }
    /**
    * 条件查询
    */
    function formSubmit1(tFormId, tToUrl,tCallBack){
    $("#currentPage").val(1);
    formSubmit(tFormId, tToUrl,tCallBack);
    }
    /**
    * form表单提交方法
    * */
    function formSubmit(formId, url,callback) {
  38.  
  39. if(url=="fund"){
    callback = "fundInit";
    }
  40.  
  41. if(url=="order"){
    callback = "orderInit";
    }
  42.  
  43. $.ajax({
    cache: false,
    type: "POST",
    url: com.webappRootPath+"/"+ url+"?",
    data: $("#" + formId).serialize(),
    async: true,
    // beforeSend:loading,
    error: function (request) {
    alert("连接超时!");
    },
    success: function (data) {
    $("#main").html(data);
    //loading_none();
    if(callback){
    var func=eval(callback);
    new func();
    }
    }
    });
    }
  44.  
  45. var ul_div=document.getElementById("ul-div");
    ul_div.style.height=window.innerHeight-90+"px";

ajax post 请求的更多相关文章

  1. ajax异步请求

    做前端开发的朋友对于ajax异步更新一定印象深刻,作为刚入坑的小白,今天就和大家一起聊聊关于ajax异步请求的那点事.既然是ajax就少不了jQuery的知识,推荐大家访问www.w3school.c ...

  2. Ajax --- 数据请求

    下面主要介绍(JS原生)数据请求的主要步骤: Ajax 数据请求步骤: 1.创建XMLHttpRequest对象 2.准备数据发送 3.执行发送 4.指定回掉函数 第一步:创建XMLHttpReque ...

  3. spring HandlerInterceptorAdapter拦截ajax异步请求,报错ERR_INCOMPLETE_CHUNKED_ENCODING

    话不多说,直接上正文. 异常信息: Failed to load resource: net::ERR_INCOMPLETE_CHUNKED_ENCODING 问题描述: 该异常是在页面发送ajax请 ...

  4. 解决YII提交POST表单出现400错误,以及ajax post请求时出现400问题

    POST表单400错误: 正确做法: Add this in the head section of your layout: <?= Html::csrfMetaTags() ?> -- ...

  5. jquery Ajax异步请求之session

    写了一个脚本,如下: $(function () { $("#btnVcode").click(function () { var receiveMobile = $(" ...

  6. ajax异步请求Response.Redirect重定向

    一个ajax异步请求报错->捕获异常->重定向错误提示页面.  一个简单的流程 结果一直搞不定.重定向无效.各种百度之. 后来突然想起 ajax的请求是不能在后台重定向的. 如果硬要重定向 ...

  7. [整理]Ajax Post请求下的Form Data和Request Payload

    Ajax Post请求下的Form Data和Request Payload 通常情况下,我们通过Post提交表单,以键值对的形式存储在请求体中.此时的reqeuest headers会有Conten ...

  8. 原生JS代码实现一个Ajax异步请求

    异步加载的方式 (1) defer,只支持IE (2) async: (3) 创建script,插入到DOM中,加载完毕后callBack 实现ajax之前必须要创建一个 XMLHttpRequest ...

  9. jQuery:多个AJAX/JSON请求对应单个回调并行加载

    因为我们使用jQuery,这意味着需要调用 jQuery.getScript 和 jQuery.getJSON 函数. 我知道这些函数都是异步执行(asyncronously)并且会延迟一段时间返回, ...

  10. jquery的ajax异步请求接收返回json数据

    http://www.jb51.net/article/51122.htm jquery的ajax异步请求接收返回json数据方法设置简单,一个是服务器处理程序是返回json数据,另一种就是ajax发 ...

随机推荐

  1. getAttribute和getParameter的简单区别

    getAttribute表示从request范围取得设置的属性,必须要先setAttribute设置属性,才能通过getAttribute来取得,设置与取得的为Object对象类型 getParame ...

  2. BLE 5协议栈-直接测试模式

    文章转载自:http://www.sunyouqun.com/2017/04/page/3/ BLE协议充分考虑了设备的测试问题,在协议栈层面提供了直接测试模式,用于执行BLE设备的RF物理层一致性的 ...

  3. linux基础—课堂随笔08_进程(转)

    进程优先级 命令 pstree -p 显示各个子线程 ps 进程状态(process state) UNIX风格:ps -ef BSD风格:ps aux 还有用到o参数,选项显示定制的信息: pid. ...

  4. JAVA内存存储分配粗略讲解

    以String类型为例:String s1 = "ABC"; String s2 = "ABC"; String s3 = new String("A ...

  5. 第一章 Vue介绍

    5 MVC和MVVM的关系图解 MVVM是前端视图层的分层开发思想,主要把每个页面,分层了M.V和VM.其中,VM是MVVM思想的核心,因为VM是M和V之间的调度者 6 Vue基本代码和MVVM之间对 ...

  6. Spring 事务相关

    事务类型 数据库事务类型有本地事务和分布式事务: 本地事务:就是普通事务,能保证单台数据库上的操作的ACID,被限定在一台数据库上: 分布式事务:涉及两个或多个数据库源的事务,即跨越多台同类或异类数据 ...

  7. WPF界面开发:DevExpress WPF在GridControl中固定行时处理时刻

    DevExpress广泛应用于ECM企业内容管理. 成本管控.进程监督.生产调度,在企业/政务信息化管理中占据一席重要之地.通过DevExpress WPF Controls,您能创建有着强大互动功能 ...

  8. 小程序wx.showToast()方法实现文字换行

    小程序wx.showToast()方法实现文字换行 在文字中间加上  '\r\n' 真机中生效 wx.showToast({ title: `换行前内容\r\n换行后内容`, icon: 'none' ...

  9. ESP8266—“ICACHE_FLASH_ATTR”宏

    问:ESP8266_NONOS_SDK中ICACHE_FLASH_ATTR宏的用途是什么?我看到它取决于ICACHE_FLASH,但我不知道何时应该定义该符号.什么时候需要包括它?答:对于ESP826 ...

  10. 8.JavaScript

    1.JavaScript简介 JavaScript主要运行在客户端,用户访问带有JavaScript的网页,网页里的JavaScript程序就会传给浏览器,由浏览器解释和处理.表单数据的有效性验证等互 ...