分类 "JavaScript" 下的文章

问题:使用fileupload如何跨域上传图片?

解决:跨域问题可以前端解决,也可以后端解决

方法:
方法一:配置fileupload

$('#fileupload').fileupload({
        url: config.getUrl()+"upload!upload.do",
        type:"POST",
        dataType:"json",
        autoUpload : true,
        acceptFileTypes: /(\.|\/)(jpe?g|png)$/i,
        formData: {model:1},
        forceIframeTransport: true,  # 实现跨域
        redirectParamName:"callUrl",
        redirect:"http://"+window.location.host+"/app/callupload.html?",  // 回调页面,接受回调

阅读全文

问题:如何使用jquery实现div的拖拽功能?

方法:

$(function() {
 //样式
 $("#drag").css({
     "position": "absolute",
     "top": "100px",
     "left": "100px",
     "border": "1px solid #789",
     "width": "150px",
     "height": "90px",
     "background": "#988f82",
     "cursor": "move"
 })

阅读全文

简介:简单的模态框代码

HTML:

<!-- 弹窗 -->
<div class="backdrop"></div>
<div class="modal-box" id="folder_modal">
    <div class="modal-content">
        <div class="modal-header">
            <label class="modal-title">移动到</label>
            <i class="fr modal-close fa fa-close"></i>
        </div>
        <div class="modal-body">
        </div>
        <div class="modal-footer">
            <button type="button" class="mt-button" id="submit_btn">确定</button>
            <button type="button" class="mt-button-light" id="cancel_btn">取消</button>
        </div>
    </div>
</div>

阅读全文

问题:layui如何获取上传的文件类型,然后修改传递的数据data?

方法:

function initUpload(self,e){
    var upload = self.upload
    var element = self.element
    var elem = '#upload-wrapper-'+e
    var module_params = '';
    btn_num = btn_num + 1;
    var btn_id = 'sub_btn_' + btn_num;
    $('#btn_box').append('<span id="'+ btn_id +'"></span>')

阅读全文

问题:如何将后台python加密的密文使用cryptoJS解密?crypto-js解密报错malformed utf-8 data

解决:注意python端Crypto模块和前端crypto-js的配合使用

方法:

python代码:

def pad(data):
    length = 16 - (len(data) % 16)
    return data + chr(length)*length

def unpad(data):
    return data[:-ord(data[-1])]

def encrypt(message, passphrase):
    IV = Random.new().read(BLOCK_SIZE)
    aes = AES.new(passphrase, AES.MODE_CFB, IV, segment_size=128)
    return base64.b64encode(IV + aes.encrypt(pad(message)))

def decrypt(encrypted, passphrase):
    encrypted = base64.b64decode(encrypted)
    IV = encrypted[:BLOCK_SIZE]
    aes = AES.new(passphrase, AES.MODE_CFB, IV, segment_size=128)
    return unpad(aes.decrypt(encrypted[BLOCK_SIZE:]))

阅读全文