Results 1 to 3 of 3

Thread: Maybe a BUG with Ajax Request using CORS?

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Mar 2017
    Posts
    4

    Default Maybe a BUG with Ajax Request using CORS?

    I've been like 24 hours trying to find the solution... My last time dealing with ExtJS was with 3.x version but ExtJS 6 is not a big deal (I though.. )
    Using
    Code:
    sencha -sd /var/www/html/ext-6.2.0 generate app -s /var/www/html/ext-6.2.0/templates/admin-dashboard/ EScheduler frontend/
    I already started my Admin Dashboard Frontend.
    COOOL!!!
    I have a restful API developed with symfony2 using FOSRestBundle and NelmioCORS.
    The server side works fine, I tested the methods using Behat Tests, Chrome Advanced Rest Client and a JQuery Script.

    JqueryWorks.jpg

    Here the JQUeryScript (That means the problem is not the browser)

    Code:
    $(document).ready(function() {    $.ajax({
                url: 'http://localhost:8000/login',
                type: 'POST',
                dataType: 'json',
                data: {
                    'username': 'admin',
                    'password': 'admin123'
                },
                async: false,
                crossDomain: true,
                success: function () { },
                failure: function () { },
                complete: function (data) {
                    if (data.readyState == '4' && data.status == '200') {
                        errorLog.push({ IP: Host, Status: 'SUCCESS' })
                    }
                    else {
                        errorLog.push({ IP: Host, Status: 'FAIL' })
                    }
                }
            });
    });
    The response headers are correct. So is not my server side config.

    This is my ExtJS code, nothing weird or complicated about it:

    Code:
    onLoginButton: function(button, e) {
            var form = button.up().getForm();
            Ext.Ajax.setCors(true);
            Ext.Ajax.setUseDefaultXhrHeader(false);
            Ext.Ajax.setDisableCachingParam(false);
            Ext.Ajax.request({
                url: Admin.Constants.BASE_URL + 'login',
                params: form.getValues(),
                method: 'POST',
                defaultHeaders:{
                    'Accept': 'application/json, text/javascript, */*; q=0.01',
                },
                // async:false,
    
    
                success: function(response, opts) {
                     var obj = Ext.decode(response.responseText);
                     console.dir(obj);
                 },
    
    
                 failure: function(response, opts) {
                   console.dir(response);
                     console.log('server-side failure with status code ' + response.status);
                 }
            });
    And the request is not going through:
    ExtDoesntWorks.jpg

    Is a BUG o I am doing something wrong? Please I wanna use ExtJS on my project... but if I can't find a solution I gonna try with OpenUI or something like that. And personally I don't like the idea.

    I am using the 6.2.0 Community Edition.

  2. #2
    Sencha User
    Join Date
    Mar 2017
    Posts
    4

    Default

    Please move it to other category. I start everything from scratch, I have the same code posted, but right now is working. I check my version control diff and I can't see nothing wrong. So is not a bug. Apologize any inconvenience

  3. #3
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985

    Default

    Thanks for the update. No inconvenience here. Glad to hear that you've gotten things up and running.

Similar Threads

  1. Replies: 8
    Last Post: 26 Jun 2017, 3:30 AM
  2. How to make an ajax request cross origin CORS
    By SurenderBhyan1 in forum Ext: Discussion
    Replies: 4
    Last Post: 23 Dec 2015, 6:44 AM
  3. Ext.Ajax.request CORS not working
    By marco.napetti in forum Ext 5: Q&A
    Replies: 5
    Last Post: 17 Oct 2014, 12:01 AM
  4. Ajax & CORS
    By Frey89 in forum Sencha Touch 2.x: Q&A
    Replies: 1
    Last Post: 16 May 2014, 8:31 AM
  5. Ext.Ajax.request with CORS problem
    By Svinja in forum Sencha Touch 2.x: Q&A
    Replies: 3
    Last Post: 14 May 2012, 3:29 PM

Tags for this Thread

Posting Permissions

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