1. #1
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Mumbai, India
    Posts
    191
    Answers
    10
    Vote Rating
    0
    bomslang has a little shameless behaviour in the past

      0  

    Default Unanswered: ExtJs4.1 - Form data not being submitted to server

    Unanswered: ExtJs4.1 - Form data not being submitted to server


    Folks,

    I am using ExtJS 4.1. I am trying to submit a form using Ext.Ajax.request() and REST on server side.

    Here's my Ajax request,
    Code:
    var params = form.getValues();
    Ext.Ajax.request({
        url: 'feedback/newFeedback.action',
        params: params,
        success: function(response) {
            Ext.Msg.alert('Success');
        },
        failure: function(response) {
            Ext.Msg.alert('Failure', 'Error : '+response.responseText);
        },
        callback: function(options, success, response) {
            Ext.Msg.alert('Title', response.responseText);
        }
    });
    Server Side code :-
    Code:
    @RequestMapping(value="/feedback/newFeedback.action")
    public @ResponseBody Map<String,? extends Object> create(@RequestBody Object data) throws Exception {
            try{
                List<Feedback> feedbacks = feedbackService.create(data);
                return getMap(feedbacks); // this will return json once control reaches here ..
            } catch (Exception e) {
                return getModelMapError("Error trying to create contact.");
            }
        }
    When I click on Submit button, I get the below error

    message: /feedback/newFeedback.action
    description The requested resource (/feedback/newFeedback.action) is not available.
    What am I missing ?
    --
    Bomslang,
    Software Engineer,
    HTML5 Developer | ExtJS, Sencha Touch, GXT Passionate | Json Supporter

    Twitter : @bomslang

    ----------------------------------------------------------------------------------

    # Learn about Sencha Products via it's Documentation : ExtJS | Sencha Touch | GXT

    # Check for correct Json here : JSONLint.com

    # Want to code Sencha Touch Online ? Try SenchaFiddle.com

    # Want to code and test ExtJS Online ? Try http://ext4all.com/ & http://jsfiddle.net/

    # Must Read : 20 things to avoid / do when starting with ExtJS or Sencha Touch

  2. #2
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Mumbai, India
    Posts
    191
    Answers
    10
    Vote Rating
    0
    bomslang has a little shameless behaviour in the past

      0  

    Default


    Now, if I try out with form.submit(), it throws me a different exception

    Code:
    var form = Ext.getCmp('fdForm').getForm();
                            if(form.isValid()) {
                                form.submit({
                                    waitMsgTitle: 'Title',
                                    url: 'feedback/newFeedback.action',
                                    method: 'POST',
                                    success: function(response) {
                                         Ext.Msg.alert('Success');
                                    },
                                    failure: function(response) {
                                         Ext.Msg.alert('Failure');
                                    }
                                });
                            }
    Exception :-
    Code:
    POST http://localhost:8080/faq/feedback/newFeedback.action 415 (Unsupported Media Type) ext-all-debug.js:37622
    Ext.define.request ext-all-debug.js:37622
    Ext.define.doSubmit ext-all-debug.js:30042
    Ext.define.run ext-all-debug.js:30016
    (anonymous function)
    What is happening ? What is wrong with my code ?

    Any sample example of form submission using REST ?


    --
    Bomslang,
    Software Engineer,
    HTML5 Developer | ExtJS, Sencha Touch, GXT Passionate | Json Supporter

    Twitter : @bomslang

    ----------------------------------------------------------------------------------

    # Learn about Sencha Products via it's Documentation : ExtJS | Sencha Touch | GXT

    # Check for correct Json here : JSONLint.com

    # Want to code Sencha Touch Online ? Try SenchaFiddle.com

    # Want to code and test ExtJS Online ? Try http://ext4all.com/ & http://jsfiddle.net/

    # Must Read : 20 things to avoid / do when starting with ExtJS or Sencha Touch

  3. #3
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    It seems that your webserver does not support request to 'http://localhost:8080/faq/feedback/newFeedback.action'. What will happen if you will access to this url by using your browser?

  4. #4
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Mumbai, India
    Posts
    191
    Answers
    10
    Vote Rating
    0
    bomslang has a little shameless behaviour in the past

      0  

    Default


    Thanks for your reply.

    I tried running it under both - Eclipse Internal web browser as well as Chrome.
    Both shows up the same error.
    --
    Bomslang,
    Software Engineer,
    HTML5 Developer | ExtJS, Sencha Touch, GXT Passionate | Json Supporter

    Twitter : @bomslang

    ----------------------------------------------------------------------------------

    # Learn about Sencha Products via it's Documentation : ExtJS | Sencha Touch | GXT

    # Check for correct Json here : JSONLint.com

    # Want to code Sencha Touch Online ? Try SenchaFiddle.com

    # Want to code and test ExtJS Online ? Try http://ext4all.com/ & http://jsfiddle.net/

    # Must Read : 20 things to avoid / do when starting with ExtJS or Sencha Touch

Thread Participants: 1

Tags for this Thread