Is there a way to halt a request that is currently being processed in the backend?

// Search panel with two buttons

    var searchPanel = new Ext.FormPanel({
        frame:true,
        title: 'Search Criteria',
        collapsible:true,
        defaultType: 'textfield',
        region:'west',
        autoScroll:true,

        // has few text boxes for input search 

        ],
        buttons: [{
            id: 'search-button',
            text:'Search',
            handler:applySearch
        },{
            id:'stop-button',
            text:'Stop',
            handler:stopSearch
        }]
    });

    function applySearch(){
        applySearchFunction('search');
    }

    function applySearchFunction() {
        //calls the store with required fields

    }

    function stopSearch(){
        //What adjustments need to be made here to abort/cancel the ongoing processing request.

    }

var reader = new Ext.data.JsonReader({
    id:'id'
    ,totalProperty:'total'
    ,root:'rows'
    ,fields:[
        // required fields
    ]
});

function handleServerTimeOutError(conn, response, options) {
    if(response.status == 504){
        Ext.Msg.alert(
           'Timed out',
            'The search operation timed out, please try again'
        );
     }
}
// The backend call takes place here.. 
var connObj = new Ext.data.Connection({
    timeout : toMS(60),
    url : 'file containing json logic',
    method : 'POST',
    listeners: {
        requestexception: handleServerTimeOutError
    }
});

var store = new Ext.data.GroupingStore({
    reader: reader,
    //use proxy so we can set timeout
    proxy : new Ext.data.HttpProxy(connObj),
    //autoLoad: 'true',
    remoteSort: true,
    listeners: {
        beforeload: startIdleTimer
    }
});

Answer №1

Consider utilizing XMLHTTPRequest.abort() For your specific situation, attempt the following

function endProcess(){
     connectionObj.abort();
}

Answer №2

It is possible to cancel an XMLHTTPRequest, however, there is no certainty that the server will cease its processing of the request.

For example, in PHP you have the option to use: ignore_user_abort(true). This functionality varies based on the technology used by your server.

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

There seems to be a JSON syntax error on the website for tracking Covid-

Hi everyone, I'm currently working on a Covid-19 tracker website and facing an issue that says: 'SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data' ; Being new to web development, I am unsure about what&apo ...

Backend is currently unable to process the request

Whenever a user clicks on a note in my notes page, a request is supposed to be made to the backend to check if the user is the owner of that particular note. However, for some reason, the request is not being processed at all. The frontend is built using ...

There seems to be an issue with [object%20Object]/undefined within the

AuthenticationService.js import axios from 'axios'; const AUTH_API_BASE_URL = "http://localhost:8087/auth"; class AuthenticationService { login(user) { return axios.post(AUTH_API_BASE_URL + "/login", user); } getRo ...

How can I make sure certain properties in the Vuex store don't retain their state after a redirect during server-side rendering (SSR)?

Our approach involves server-side rendering with the use of preserveState to persist all vuex modules' state when navigating between pages. However, we have a specific store where we need to exclude certain properties from persistence. Is there a sol ...

What is the best way to fetch and convert information from an API to display on a website?

I am encountering an issue while trying to retrieve data from an API. Below is my code with a fabricated access code. $(function () { var $data = ('#data'); $.ajax({ type: 'GET', url: 'http://api.openweathe ...

Refresh an HTML page using Selenium WebDriver and Python without the need to actually refresh the entire

On a page with self-refreshing content (via WebSocket) similar to this example, the constantly changing content is not being detected by my Firefox webdriver. Although the new content is visible in the Firefox window, my webdriver only captures the initial ...

Phonegap - Retaining text data in a checklist app beyond app shutdown

This is my first time developing an app with Phonegap. I am looking to create a checklist feature where users can input items into an input field. However, I am struggling with figuring out how to save these items so that they remain in the checklist even ...

Parsing JSON sub items in Android application using Java

Here is a snippet of my PHP file: <?php $myObj = array( "name"=>"John" , "age"=>"30" , "post"=>[ "title"=>"What is WordPress" , "excerpt"=>"WordPress is a popular blogging platform" , ...

Unable to connect to Alpine store from an external source due to a typescript error

Here is how I have configured my Alpine store: Alpine.store( 'state', ({ qr: '' })) Now, I am attempting to update it from an external source as follows: Alpine.store( 'state' ).qr = 'test' However, I am encounte ...

Exploring Elasticsearch: Uncovering search results in any scenario

I've been working on a project where my objective is to receive search engine results under all conditions. Even if I enter a keyword that is not included in the search data or if it is an empty string, I still want to get some kind of result. How can ...

Incorporating Content Dynamically with JavaScript AJAX Functions

I've recently developed a webpage that utilizes an AJAX call to populate a specific div with the following content: <div class="latest-jobs"> <ul class="list-of-jobs"> <li> < ...

Troubleshooting: Issues with TextureLoader causing image rendering failure in three.js

Here is the approach I take to incorporate an image using three.js - rendererModule.addImage = function (primitive){ var self = this; var textureLoader = new THREE.TextureLoader(); console.log("This is step 1"); textureLoader.load("image/m ...

What is the process for creating a server-side API call?

I've designed a front-end application that uses an API to retrieve data. The problem I'm facing is that in order to access the API, I need to use an API Key. If I include the API key in the client-side code, it will be visible to users. How can I ...

What is the best way to animate the scaling of a CSS property using jQuery?

I need help creating an animation where a circle div with the class of "bubble" grows from nothing to its full size when a button is clicked using jQuery. I am currently facing difficulties in making it work properly. Here's my current code snippet: ...

Converting a multi-dimensional array to a single array in JavaScript: the ultimate guide!

I have encountered a scenario in my application where there is an array with multiple arrays nested inside: https://i.sstatic.net/3uHP9.png I am looking to transform this structure: [ { "tag": [ { "key": "asda ...

What is the best way to delete an input field once it has been cleared?

After scouring through resources, I found a way to dynamically add input fields on keystroke by referencing an answer from this question. To see my implementation, check out this example. However, one challenge remains - removing a field if the user delete ...

Enhancing the Performance of Asp.net MVC SPA App through Server-Side Rendering

We are aiming to optimize the performance of our single page application built in asp.net mvc. The current framework consists of: Server-side Asp.net mvc communicating with an SQL Database Client-side SPA developed using JS/Html5 + requireJS and KendoUI ...

An error stating that "DataTable is not a recognized function" occurred within the document function

Previously, I set up datatables using the code below: $(function () { $('#keywords-table').DataTable({ "ajax": ({ url: "{{ route('getKeywordsByProductId') }}", method: "get", ...

The change event for Bootstrap 4 switches is not functioning as expected

I am facing an issue with multiple Bootstrap 4 switches that are dynamically loaded onto the page using JS append. I need to call a function when the switch changes. The example below works fine when the switches are added in HTML, but it doesn't work ...

What is the best way to use jQuery to increment the number in an input field by a specific value?

My goal is to utilize jQuery to increment a number in an input field and then display the updated value in the same input field. The specific id of this input field is "total". Here's my attempt so far: function addBag(){ var bagprice = 79.99; ...