1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    10
    Vote Rating
    0
    y.elqandili1 is on a distinguished road

      0  

    Default Ajax lways giving me failure

    hey guys,

    i'm trying to use ajax for the first time with sencha, the problem is that my code always leads to failure and i dont know why cause my code seems to be right.
    Code:
     Ext.Ajax.request({
                                            url : 'contact.php',
                                            success : function(response){
                                                var a = response.responseText;
                                                alert(a);
                                            },
                                            failure: function(response){
                                                Ext.Msg.alert(response.responseText);
                                            }
                                        });

  2. #2
    Sencha User Tim Toady's Avatar
    Join Date
    Feb 2010
    Location
    Pennsylvania
    Posts
    580
    Vote Rating
    269
    Tim Toady has much to be proud of Tim Toady has much to be proud of Tim Toady has much to be proud of Tim Toady has much to be proud of Tim Toady has much to be proud of Tim Toady has much to be proud of Tim Toady has much to be proud of Tim Toady has much to be proud of

      0  

    Default

    Your request looks ok. Is there something in your php that is failing? Is the data coming back actually json? In what way does it fail? Do you receive any errors?

  3. #3
    Sencha User
    Join Date
    Jul 2012
    Posts
    10
    Vote Rating
    0
    y.elqandili1 is on a distinguished road

      0  

    Default

    Well my in my php file there's a simple echo "right";
    and i got no errors, it's only the alert i did in the failure clause. I don't know what's wrong :S

  4. #4
    Sencha User Tim Toady's Avatar
    Join Date
    Feb 2010
    Location
    Pennsylvania
    Posts
    580
    Vote Rating
    269
    Tim Toady has much to be proud of Tim Toady has much to be proud of Tim Toady has much to be proud of Tim Toady has much to be proud of Tim Toady has much to be proud of Tim Toady has much to be proud of Tim Toady has much to be proud of Tim Toady has much to be proud of

      0  

    Default

    Does the alert actually say the word "right"? Are you sure it is the alert in the failure callback since it is the same thing as the one in the success callback? I can take your alert put it in firebug and have it work if I also create the php contact.php file with an echo "right" in it. Is your contact.php in the right location? There has to be something different or a missing detail.

  5. #5
    Sencha User
    Join Date
    Jul 2012
    Posts
    10
    Vote Rating
    0
    y.elqandili1 is on a distinguished road

      0  

    Default

    the file contact.php is in the same folder as the script and for failure code it wasnt the same i just chenged to so as i see if there's a diffrence. it was an alert that says wrong... For what I see everything should work correctly but something is not working what is it I don't know!! .. but thank u any way for your time ^^.. i you find something just tell me

  6. #6
    Sencha User
    Join Date
    Jul 2012
    Posts
    10
    Vote Rating
    0
    y.elqandili1 is on a distinguished road

      0  

    Default

    thanks Tim .. it worked now .. i guess that the app considers that its in the parent folder of the app so I had to change the location from "contact.php" to "app/view/contact.php" and it worked.. Yaay

Thread Participants: 1

Tags for this Thread