zoukankan      html  css  js  c++  java
  • sell--前台传输数据到后台的几种方式

    1.

    //ajax 前提:
    $ = $ || {};
    $.postJSON = function(url, data) {
        return $.ajax({
            url: url,
            data: JSON.stringify(data),
            dataType:'json',
            contentType: 'application/json; charset=utf-8',
            type: 'post'
        })
    };
    
    //1. 第一种: <s:url action...
    <a href="<s:url action="china-craft-export"/>" class="btn blue" target="_blank">下载中国大货库存 excel</a>
    <a href="<s:url action="china-craft-download-template"/>" class="btn blue" target="_blank">下载大货更新模板</a>
    
    //2.第二种: input控件的location
    <input type="button" onClick='location="/codelib/log-detail.jhtml?stockLog.id=<s:property value="#log.id"/>"' value="view detail" class="input_btn" />
    
    //3.第三种: form 提交
    //3.1
     <form action="/cart/addCart.jhtml" method="post" name="sizelist<s:property value="#productDTO.id" />">....
    	<input type="submit" value="" class="input_sub" />
    
    //4.第四种: ajax提交
     	   var param = "calcelOrderId="+id;
    	    $.ajax({
    	        async:false,
    	        data:param,
    	        url:"../backoffice/cancelOrder.jhtml",
    	        timeout:5000
    	    });
    
    //5. 第五种:window.open/ window.location
    window.open("/order/invoiceApplicationForm.jhtml?"+params);
    
    // coffee
    class Model
        searchText: ko.observable('')
        boxes: ko.observableArray()
        info: ko.observable('')
        pageSize: 30
        boxNames: ko.observableArray()
        search: =>
            $.postJSON('/pfizer/search.json', {search: @searchText(), page: 0, pageSize: @pageSize})
            .done (pageResult) =>
                @boxes.removeAll()
                for box in pageResult.result
                    box.date = moment(box.createdAt).format('YYYY-MM-DD')
                    @boxes.push box
                @info("total: #{pageResult.totalCount}, show: #{@boxes().length}")
            return false
        downloadExcel: =>
            window.open '/pfizer/download-excel.jhtml?_=' + new Date().getTime()
        downloadExcelBox: (box) =>
            tick = new Date().getTime()
            window.open "/pfizer/download-excel-box.jhtml?_=#{tick}&boxId=#{box.id}&boxName=#{box.name}"
        downloadExcelBoxes: =>
            window.open '/pfizer/download-excel-boxes.jhtml?_=' + new Date().getTime()
        showBox: (box) =>
            window.open "/pfizer/edit-box.jhtml?boxId=#{box.id}&searchText=#{@searchText()}"
        loadBox: =>
            boxId = +$('#chooseBox').val()
            if boxId
                $.postJSON('/pfizer/search.json', {boxId: boxId, page: 0, pageSize: @pageSize})
                .done (pageResult) =>
                    @boxes.removeAll()
                    for box in pageResult.result
                        box.date = moment(box.createdAt).format('YYYY-MM-DD')
                        @boxes.push box
                    @info("total: #{pageResult.totalCount}, show: #{@boxes().length}")
    
  • 相关阅读:
    Linux下修改Apache即httpd的端口
    jenkins.JenkinsException: Error in request. Possibly authentication failed
    jenkins-python 获取正在运行的Job
    通过python-jenkins 获取job的输出日志
    电子公文传输系统团队项目
    接口重复请求报错问题排查
    创建couchbase的bucket 提示RAM不够用 all the ram in the cluster is already allocated to existing bucekets,delete some buckets,,
    tornado重定向的几种方式
    tornado进行登录案例
    tornado设置cookie和查看cookie,含加密
  • 原文地址:https://www.cnblogs.com/bravolove/p/6072504.html
Copyright © 2011-2022 走看看