How To Make AJAX Calls With ExtJS Easily Como fazer chamadas com AJAX facilmente ExtJS
Simple things should be simple. Simples coisas deveriam ser simples. 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. Embora começando com ExtJS, eu vi um screencast Grid em que utilizou um método bastante duvidosa AJAX de fazer uma chamada utilizando uma forma real elemento. I hunted for a better option and I came across a better option - Ext.data.Connection. Eu caçados para uma melhor opção e eu vim através de uma melhor opção - Ext.data.Connection. Here’s an working example on how you can easily make AJAX call in ExtJS library. Aqui está um exemplo de trabalho sobre a forma como você pode facilmente fazer AJAX chamada em ExtJS 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.'); } }); Lig var = new Ext.data.Connection (); conn.request ((url: "history.jsp ', método:' POST ', parâm: (" metaID ": metaID, columnName: campo), sucesso: function (responseObject ) (ShowHistoryDialog (responseObject.responseText);), fracasso: function () (Ext.Msg.alert ( 'Estado', 'Não foi possível demonstrar história neste momento. Por favor, tente novamente mais tarde. ");))); Obviously you will have to implement the showHistoryDialog() method to your taste. Obviamente você terá que executar o showHistoryDialog () método para o seu gosto. Change the method names and url to suit your requirements. Altere o método nomes e url para atender às suas necessidades.
The downside is that it doesn’t display a loading message which you can easily implement. A desvantagem é que ela não será exibida uma mensagem carga que você pode facilmente implementar.
Update:
Here is the full code showing a Loading dialog too: Aqui está o código completo mostrando uma carga demasiado diálogo:
var conn = new Ext.data.Connection(); // History buton click handler.Lig var = new Ext.data.Connection () / / História buton clique manipulador.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.'); } }); } }Alega o pedido e exibe a resposta utilizando história diálogo função showHistory () (if (registro! = Null & & campo! = Null) (metaID = record.get ( "MetaID"); grid.getGridEl (). Máscara ( 'Carregando História ...'); conn.request ((url: "history.jsp ', método:' POST ', parâm: (" metaID ": metaID, columnName: campo), sucesso: function (responseObject) (showHistoryDialog (responseObject . responseText); grid.getGridEl (). desmascarar (true);), fracasso: function () (grid.getGridEl (). desmascarar (true); Ext.Msg.alert ( 'Estado', 'Não foi possível mostrar a história desta vez. Por favor, tente novamente mais tarde. ");)));))
Note: The code is used in a production environment to display historical information. Nota: O código é utilizado em um ambiente de produção para exibir informações históricas. The server side code as well as the implementation of of showHistoryDialog() is not provided as it is irrelevant to the context. O código lado do servidor, bem como a implementação da de showHistoryDialog () não está previsto e é irrelevante para o contexto.
With libraries like ExtJS and services like GMail, browser is now truly the king. ExtJS como com as bibliotecas e os serviços como o Gmail, do navegador está agora verdadeiramente o rei. You don’t need desktop applications for most purposes. Você não precisa aplicações desktop para a maioria dos propósitos.
Filed under Arquivado em Ajax , De Browser Navegador , De Headline News Headline News , De How To How To , De Javascript , De Programming Programação , De Web , De Web 2.0 Web 2,0 , De Web Services Web Services | |
| |
RSS 2.0 RSS 2,0 | |
Trackback this Article | este artigo |
Email this Article E-mail este artigo
You may also like to read Você pode também gosta de ler |





August 27th, 2007 at 2:13 am 27 de agosto de 2007 em 2:13 am
Ext kan eenvoudige zaken nog eenvoudiger maken. Ext Kan eenvoudige zaken Nog eenvoudiger maken.
Je kan Ext.Ajax.request gebruiken om een Je Kan Ext.Ajax.request gebruiken om een
call uit te voeren, is nog net iets korter dan de connection oplossing. chamada UIT te voeren, é Nog net iets korter dan de conexão oplossing.
Overigens gebruikt ook eens Ext.encode om Overigens gebruikt om ook eens Ext.encode
je parms te encoderen, JE parms TE encoderen,
March 11th, 2008 at 4:09 pm 11 de março de 2008 em 4:09 pm
Thank you very much! Muito obrigado! After much digging around (including extjs.com), that\\\’s exactly what I need. Depois de muito cavar em torno (incluindo extjs.com), que \ \ \ 's exatamente o que eu preciso.