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}")
    
  • 相关阅读:
    DRF的Filter:字段过滤,查找,排序
    DRF的ViewSet和Router
    DRF的APIView和mixins+GenericAPIView和ListAPIView
    DRF的Serializer和ModelSerializer
    html5中的drag
    excel与json转换
    call和bind的原生实现
    将字符串转化为条形码,在将canvas转化为图片
    JSON与excel之间的相互转化(Vue)
    js实现点击复制,将内容复制至剪贴板
  • 原文地址:https://www.cnblogs.com/bravolove/p/6072504.html
Copyright © 2011-2022 走看看