Is it possible to read an XML response as a stream using Ext JS?

Requesting an XML response can sometimes result in a slow completion time due to certain constraints. Despite this, the data begins returning quickly.

I am wondering if it is feasible to read the response stream in Ext JS before it is fully complete. My understanding is that *Readers typically receive the response text only once it has finished processing.

Answer №1

Ext.Proxy for Comet techniques does not currently exist and would present a challenging task to implement. The process would involve creating a Sax parser to interpret an incomplete XML document and then developing a proxy that can execute operations as new data is received. While ExtJS is not inherently suited for this functionality, the possibility of creating such a proxy is intriguing. It is important to note that any implemented Ext.Proxy would have unique behavior compared to other proxies, requiring different methods and interfaces.

On a different note, triggering an event when receiving stream chunks is achievable in Gecko and WebKit browsers by attaching a handler to the onreadystate event of XHR. This event will be triggered whenever data is received.

For experimental purposes:

Ext.define('Ext.proxy.StreamEventedAjax',{
    extend: 'Ext.proxy.Ajax',
    doRequest: function(operation, callback, scope) {

        if (Ext.isIE) return null;

        // Additional setup for doRequest here, utilizing buildRequest, etc

        var me = this,
            req = new XMLHttpRequest(),
            responseLength = 0,
            newText = "";
        req.onreadystate = function(e) {

           newText = req.responseText.substring(responseLength);
           responseLength = req.responseText.length;

           operation.fireEvent('datareceived',e,newText);

        }

        req.open(me.getMethod(request),request.url);

    }
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Sending user credentials to a new page in JavaScript

My goal is to direct the user from one web page to another that requires a password for access. The user arrives on the initial page by scanning a barcode with a specific terminal, similar to a smartphone equipped with a customized barcode reader applicati ...

Retrieve data with a web API

I am currently developing a web API to fetch data from a mock database using express My goal is to retrieve a JSON list containing all portfolios and their corresponding positions from the database module. Is there a way to structure the returned data so ...

Guide to packaging TypeScript type declarations with an npm JavaScript library

I'm facing an issue with providing TypeScript type definitions for a JavaScript library. The library itself is written in TypeScript and transpiled by Babel, although this detail shouldn't affect the outcome. The problem lies in the fact that ne ...

My jQuery AJAX request is not successfully communicating with my PHP script

I am not well-versed in AJAX (or jQuery), but I believed my task was fairly straightforward. However, when attempting to send an AJAX request using: $.ajax( requestObj ); it seems to fail, and I am seeking assistance. To provide context, here is how the ...

Store the running of a JavaScript file in memory

It seems highly unlikely that achieving the following is possible without expert confirmation: On page number 1, user and application data is requested as soon as the page loads. Page number 2 utilizes the same script, so requesting the same information w ...

When I tried running a basic AJAX JQuery code snippet, it unexpectedly threw a 500 internal

Hey there! I'm currently working on a Spring MVC project and encountering an error when I click the button in my form. 500 (Internal Server Error) jquery.min.js:6 x.ajaxTransport.x.support.cors.e.crossDomain.send j ...

Is it possible to combine Ajax, JS, HTML, PHP, and MySQL in a single project?

I am looking to create a web application and wondering if I can integrate Ajax, JavaScript, HTML, PHP, and MySQL all together? ...

Typescript HashMap implementation with Lists as values

Currently delving into TypeScript, I am attempting to generate a collection in a manner akin to the following Java example: HashMap<String, List<String>> hashMap = new HashMap<String,List<String>>(); Struggling to locate any releva ...

Tips on waiting for a screenshot of a webpage to be captured using Selenium and PhantomJS in Python 3

Want to capture an image of a webpage, but need it to fully load (including AJAX) first. The delay time should be predetermined instead of being reliant on a specific element. The code below takes a screenshot without waiting: from selenium import webdr ...

Is it necessary to incorporate express in a Next.js project?

I'm currently working on a website using Next.js. With Next.js, I have access to features like SSR and dynamic routing. Is it necessary for me to incorporate express into my project? If yes, what are the reasons behind needing to use it? What unique ...

Swapping values in JSON by comparing specific keys: A guide

I have JSON data that contains a key called reportData with an array of values: {"reportData":[ ["1185","R","4t","G","06","L","GT","04309","2546","2015","CF FE","01H1","20","23840","FF20"], ["1186","R","5t","R","01","L","TP","00110","1854","2016" ...

Using an AJAX self-invoked function to update Vue data

I have been attempting to utilize a self-invoked function for an ajax call. However, I am facing issues when trying to use the response to populate a data property within Vue. This is the code I have implemented: //Ajax call to service var getData = (fun ...

Enabling hover effects to scroll divs only when interacted with

I am aiming to achieve two separate scrolling divs and I'm uncertain about the exact approach. Experimenting with various overflow properties has only resulted in one scrolling independently. .profile { width: 100%; display: flex; ...

data being returned twice onpopstate

After experimenting with onpopstate, I encountered an issue. When I click the back button in my browser, the URL changes as expected, but the page code loads twice, resulting in duplicate lists and div elements. Why is this happening and how can it be reso ...

The concept of global object/scope and circular references in undefined cases

Trying to make sense of the outcomes from these few experiments : Experiment number 1 (in a new command line) : > _ ReferenceError: _ is not defined at repl:1:2 at REPLServer.self.eval (repl.js:110:21) at Interface.<anonymous> (repl. ...

Steps to display a div element periodically at set time intervals

I've created a user greeting message that changes based on the time of day - saying Good Morning, Good Afternoon, or Good Evening. It's working well, but I'm wondering how I can make the message hide after it shows once until the next part o ...

Client-side script in ASP.Net Ajax, fetching the source

While exploring various examples of asp.net ajax client-side scripts, I have come across the following: function fHelloWorld(source, eventArgs) { } When I run an alert on the source, it is returned as an object. Is it possible to use this to access what ...

What are the steps to designing your own unique custom button with Material-UI?

While Material-UI allows you to utilize withStyles() for creating a Button with a predefined set of styles, I am curious if it is achievable to achieve the same result using props instead. This would ensure that all custom buttons I create automatically ha ...

Ways to verify user authentication for navigating Vue routes

Working on a Single Page Application with Vue front-end, Express, and Parse (parse-platform) for back-end. After authenticating the user, I store their info in a session variable req.session.user = result; before sending it back to the client using res.sta ...

Dispatching information to a designated Google Analytics tracking code

Within our website, we have a unique dimension that is configured on Google Analytics and utilized when sending the page view event: gtag('config', 'UA-TrackingCode', { 'custom_map': { 'dimension1': &apo ...