How To Make AJAX Calls With ExtJS Easily Come fare chiamate con AJAX ExtJS facilmente
Simple things should be simple. Cose semplici deve essere semplice. While starting with ExtJS, I saw a screencast on Grid which used a rather dubious method of making an AJAX call using an actual form element. Mentre a partire ExtJS, ho visto uno screencast sulla griglia che ha utilizzato un metodo piuttosto dubbia di rendere un AJAX chiamata utilizzando un vero e proprio elemento di forma. I hunted for a better option and I came across a better option - Ext.data.Connection. I caccia per una migliore opzione e mi sono imbattuto in una migliore opzione - Ext.data.Connection. Here’s an working example on how you can easily make AJAX call in ExtJS library. Ecco un esempio di come si può facilmente rendere AJAX ExtJS chiamata in biblioteca.
var conn = new Ext.data.Connection(); conn.request({ url: 'history.jsp', method: 'POST', params: {"metaID": metaID, columnName: field}, success: function(responseObject) { showHistoryDialog(responseObject.responseText); }, failure: function() { Ext.Msg.alert('Status', 'Unable to show history at this time. Please try again later.'); } }); var conn = new Ext.data.Connection (); conn.request ((url: 'history.jsp', il metodo: 'post', params: ( "metaID": metaID, ColumnName:) campo, il successo: funzione (responseObject ) (ShowHistoryDialog (responseObject.responseText);), in caso di avaria: function () (Ext.Msg.alert ( 'Statuto', 'Impossibile mostrare la storia in questo momento. Riprova più tardi.');))); Obviously you will have to implement the showHistoryDialog() method to your taste. Ovviamente si dovranno attuare la showHistoryDialog () metodo al vostro gusto. Change the method names and url to suit your requirements. Cambiare il metodo di nomi e url per soddisfare le vostre esigenze.
The downside is that it doesn’t display a loading message which you can easily implement. L'aspetto negativo è che non visualizza un messaggio di carico che è possibile implementare facilmente.
Update: Aggiornamento:
Here is the full code showing a Loading dialog too: Ecco il codice completo che mostra una finestra di dialogo Caricamento troppo:
var conn = new Ext.data.Connection(); // History buton click handler.var conn = new Ext.data.Connection (); / / Storia buton fare clic su gestore.It submits the request and displays the response using history dialog function showHistory() { if(record != null && field != null) { metaID = record.get("MetaID"); grid.getGridEl().mask('Loading history...'); conn.request({ url: 'history.jsp', method: 'POST', params: {"metaID": metaID, columnName: field}, success: function(responseObject) { showHistoryDialog(responseObject.responseText); grid.getGridEl().unmask(true); }, failure: function() { grid.getGridEl().unmask(true); Ext.Msg.alert('Status', 'Unable to show history at this time. Please try again later.'); } }); } }Essa sostiene la richiesta e la risposta viene visualizzata la finestra di dialogo con la storia funzione showHistory () (if (record! = Null & & campo! = Null) (metaID = record.get ( "MetaID"); grid.getGridEl (). Maschera ( 'Caricamento in corso storia ...'); conn.request ((url: 'history.jsp', il metodo: 'post', params: ( "metaID": metaID, ColumnName:) campo, il successo: funzione (responseObject) (showHistoryDialog (responseObject . responseText); grid.getGridEl (). smascherare (true);), in caso di avaria: function () (grid.getGridEl (). smascherare (vero); Ext.Msg.alert ( 'Statuto', 'Impossibile mostrare storia questo momento. Riprova più tardi. ');)));))
Note: The code is used in a production environment to display historical information. Nota: Il codice è utilizzato in un ambiente di produzione per visualizzare informazioni storiche. The server side code as well as the implementation of of showHistoryDialog() is not provided as it is irrelevant to the context. Il codice lato server, nonché l'attuazione di showHistoryDialog di () non è previsto in quanto non è pertinente al contesto.
With libraries like ExtJS and services like GMail, browser is now truly the king. Con le biblioteche come ExtJS e servizi come Gmail, il browser, ora è davvero il re. You don’t need desktop applications for most purposes. Non hai bisogno di applicazioni desktop per la maggior parte degli scopi.
Filed under Elencato sotto Ajax , Browser , Headline News Headline News , How To Come , Javascript , Programming Programmazione , Web , Web 2.0 2,0 web , Web Services Servizi Web | |
| |
RSS 2.0 RSS 2,0 | |
Trackback this Article | questo articolo |
Email this Article Invia questo articolo
You may also like to read Si può anche leggere come |




August 27th, 2007 at 2:13 am Ago 27, 2007 at 2:13 am
Ext kan eenvoudige zaken nog eenvoudiger maken. Ext eenvoudige kan nog zaken eenvoudiger maken.
Je kan Ext.Ajax.request gebruiken om een Ext.Ajax.request je kan gebruiken om een
call uit te voeren, is nog net iets korter dan de connection oplossing. chiamata uit te voeren, è netto nog iets korter dan de oplossing connessione.
Overigens gebruikt ook eens Ext.encode om Overigens gebruikt ook eens om Ext.encode
je parms te encoderen, JE parms TE encoderen,
March 11th, 2008 at 4:09 pm 11 Marzo 2008, 4:09 pm
Thank you very much! Grazie mille! After much digging around (including extjs.com), that\\\’s exactly what I need. Dopo molto scavare intorno (tra cui extjs.com), che \ \ \ \ \ 's esattamente che cosa ho bisogno.