Results 1 to 2 of 2

Thread: Ext.Ajax.request [DELETE] method not works as my expect

  1. #1
    Sencha Premium User
    Join Date
    Jan 2018
    Posts
    6

    Arrow Ext.Ajax.request [DELETE] method not works as my expect

    Code:
    Ext.Ajax.request({
    url: `/api/${url}`,
    method: 'DELETE',
    params: {
    ip: ipList,
    },
    });


    this is my code. and I expect it's working like

    /api/url?ip=1.1.1.1&ip=1.1.1.2

    but it works like

    Form Data
    ip: 1.1.1.1
    ip: 1.1.1.2

    They put params to the Form Data, not in query parameter.


    Is it bug or Am I using wrongly?

    Please help me.

    Thanks,

  2. #2

    Join Date
    Feb 2011
    Location
    Chisinau, Moldova
    Posts
    316
    Answers
    64

    Default

    You are not doing anything wrong. The params are appended to url only in case of GET requests. The request options are built in the Ext.Data.Connection class, and specifically in the setOptions method.
    If you look down near the end of the method you can see the following lines:
    Code:
        // if the method is get or there is json/xml data append the params to the url 
        if ((method == 'GET' || data) && params) {
            url = Ext.urlAppend(url, params);
            params = null;
        }
    Interestingly enough, also in this method, immediately after the previous excerpt of code, there is a possible answer to your problem:
    Code:
        // allow params to be forced into the url
         if (urlParams) {
            url = Ext.urlAppend(url, urlParams);
        }
    This is not documented, but it seems that if you can pass a `urlParams` config to your ajax request and it would force the params into the url:

    Code:
        Ext.Ajax.request({
            url: `/api/${url}`,
            method: 'DELETE',
            urlParams: {
                ip: ipList,
            }
        });
    Or you could also manually append the params to your url:
    Code:
        Ext.Ajax.request({
            url: Ext.urlAppend(
                `/api/${url}`,
                Ext.Object.toQueryString({ ip: ipList, })
            ),
            method: 'DELETE'
        });

Similar Threads

  1. Ajax.request Works Locally, not Remotely
    By MaximusW in forum Sencha Touch 1.x: Discussion
    Replies: 1
    Last Post: 22 Aug 2011, 6:40 AM
  2. Using HTTP DELETE or PUT methods with Ext.data.Connection or Ext.ajax.request
    By Virtual Ark in forum Ext 3.x: Help & Discussion
    Replies: 6
    Last Post: 9 Feb 2011, 8:03 PM
  3. Ext.Ajax.request PUT and DELETE
    By dliu120 in forum Sencha Ext JS Q&A
    Replies: 1
    Last Post: 15 Sep 2010, 8:47 AM
  4. EXT AJAX method 'DELETE' issue
    By sam_ware in forum Ext 2.x: Help & Discussion
    Replies: 5
    Last Post: 21 Jun 2009, 9:39 PM
  5. [2.1][CLOSED] Bug using DELETE Ajax method
    By Noff in forum Ext 2.x: Bugs
    Replies: 2
    Last Post: 10 Jul 2008, 5:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •