2014-09-24 62 views
0

我有一個按鈕,我想按下並將我帶到網頁。我需要在請求中包含發佈數據,並希望收到放在iframe中的HTML。按鈕上的ExtJS POST單擊

這是我認爲的代碼看起來

buttons: [ 
     { 
      text: "link", 
      handler: function(){ 
       Ext.Ajax.request({ 
        url: 'http://www.createbarcode.com/', 
        method: 'POST', 
        params: { 
         barcodeData: Ext.getCmp('BarcodeField') 
        }, 
        success: function(response, conn) { 
         //Create iframe window with response HTML 
        }, 
        failure: function(response, conn) { 
         var data = Ext.decode(response.responseText); 
         alert("Failure: " + data.msg); 
        } 
       }); 
      } 
     } 
    ] 

感謝。

+0

那究竟是什麼問題? – lascort 2014-09-24 15:40:45

+0

通過href:'www.google.com',目標:'_blank'按鈕會將您帶到新標籤中的網頁。如何包含POST數據並在新選項卡中打開網頁? – user4067565 2014-09-24 15:47:40

+0

爲什麼要打開新標籤中的網頁?如果你這樣做,你是Ext JS應用程序將無法知道響應的結果。這聽起來像你需要更好地設計和描述你需要做什麼,然後詢問如何完成它。 – existdissolve 2014-09-24 19:21:35

回答

0

這是我落得這樣做,不知道其權利,但它的工作原理,並可能在正確的方向

//Load scripts 
    Ext.Loader.loadScript('bwip-js/bwip.js'); 
    Ext.Loader.loadScript('bwip-js/lib/baropts.js'); 
    Ext.Loader.loadScript('bwip-js/lib/canvas.js'); 
    Ext.Loader.loadScript('bwip-js/lib/jquery-1.4.1.js'); 
    Ext.Loader.loadScript('bwip-js/lib/needyoffset.js'); 
    Ext.Loader.loadScript('bwip-js/lib/symdesc.js'); 
    Ext.Loader.loadScript('bwip-js/bwipp/code128.js'); 

這是幾乎從bwipjs演示代碼

buttons: [ 
     { 
      text: 'Generate Code', 
      handler: function(){ 
       var elt = Ext.getCmp('symbol').getValue(); 
       var text = Ext.getCmp('symtext').getValue().replace(/^\s+/,'').replace(/\s+$/,''); 
       var altx = Ext.getCmp('symaltx').getValue().replace(/^\s+/,'').replace(/\s+$/,''); 
       var opts = Ext.getCmp('symopts').getValue().replace(/^\s+/,'').replace(/\s+$/,''); 

       BWIPJS.load = function(path) { 
       } 

       var bw = new BWIPJS; 

       var tmp = opts.split(' '); 
       opts = {}; 
       for (var i = 0; i < tmp.length; i++) { 
        if (!tmp[i]) 
         continue; 
        var eq = tmp[i].indexOf('='); 
        if (eq == -1) 
         opts[tmp[i]] = bw.value(true); 
        else 
         opts[tmp[i].substr(0, eq)] = bw.value(tmp[i].substr(eq+1)); 
       } 

       // Add the alternate text 
       if (altx) 
        opts.alttext = bw.value(altx); 

       // Add any hard-coded options required to fix problems in the javascript 
       // emulation. 
       opts.inkspread = bw.value(0); 
       if (needyoffset[elt.sym] && !opts.textxalign && !opts.textyalign && 
        !opts.alttext && opts.textyoffset === undefined) 
        opts.textyoffset = bw.value(-10); 

       bw.bitmap(new Bitmap); 

       bw.scale(2,2); 

       bw.push(text); 
       bw.push(opts); 

       try { 
        bw.call(elt); 
        bw.bitmap().show('canvas','N'); 
       } catch(e) { 
        var s = ''; 
        if (e.fileName) 
         s += e.fileName + ' '; 
        if (e.lineNumber) 
         s += '[line ' + e.lineNumber + '] '; 
        alert(s + (s ? ': ' : '') + e.message + elt); 
       } 
      } 
     } 
    ] 
複製指向某人