zoukankan      html  css  js  c++  java
  • ajax post 请求

    $(".login_btn").click(function(){

    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)

    if (data['user']!=null) {
    window.location.href = com.webappRootPath + "/main1";

    }
    }
    });

    // 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"});

    }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)

    if (data['user']!=null) {
    window.location.href = com.webappRootPath + "/main2";

    }
    }
    });


    } 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;
    }

    $(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";

    }
    }
    });
    }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)

    if (data['user']!=null) {
    window.location.href = com.webappRootPath + "/main2";

    }
    }
    });

    } 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");
    });



    $("#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) {

    if(url=="fund"){
    callback = "fundInit";
    }

    if(url=="order"){
    callback = "orderInit";
    }

    methord = "POST";
    if(!methord){
    methord = "GET";
    }

    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) {

    if(url=="fund"){
    callback = "fundInit";
    }

    if(url=="order"){
    callback = "orderInit";
    }

    $.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();
    }
    }
    });
    }

    var ul_div=document.getElementById("ul-div");
    ul_div.style.height=window.innerHeight-90+"px";
  • 相关阅读:
    [总结]FFMPEG视音频编解码零基础学习方法--转
    ffmpeg中swscale 的用法
    FFmpeg解码H264及swscale缩放详解
    C++: std::string 与 Unicode 如何结合?
    SpringBoot-@RequestParam
    SpringBoot --web 应用开发之文件上传
    Java并发编程:线程池的使用
    Executor线程池的最佳线程数量计算
    并发下线程池的最佳数量计算
    根据CPU核心数确定线程池并发线程数
  • 原文地址:https://www.cnblogs.com/yanghongfei/p/6964429.html
Copyright © 2011-2022 走看看