Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7912181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:32:01+00:00 2026-06-03T13:32:01+00:00

In my VIew, i have added a button and when i click on it,

  • 0

In my VIew, i have added a button and when i click on it, the Controller class gets called. The value’s in the View (textfield values) , will be sent over the URL from the web service. Then the server will return a JSON string shown below;

{“value”:”SUCCESS”}

Now, i need to sent this JSON string back to the view, and the view will alert the user depending on the JSON response. If the JSON returned SUCCESS, then a Success alert will get displayed and if the JSON returned FAIL, then a Fail alert will be displayed.

1.) In my code, i can only display the JSON response from the VIEW, but how can i send it to the COntroller ? (var text = response.responseText; displays the JSON response)

2.) How could i, separate the string from the view, and only get the SUCCESS or FAIL string from the JSON response ?

Button Implementation, From the View Class

xtype:'button',
                   id:'when_button_click',
                   text:'Send',
                   ui:'confirm',

The COntroller CLass

Ext.define(‘myapp.controller.testcont’, {

                  extend: "Ext.app.Controller",
                  config: {
                  refs: {
                  newNoteBtn: "#when_button_click"
                  },
                  control: {
                  newNoteBtn: {
                  tap: "onNewNote"
                  }
                  }
                  },
                  onNewNote: function () {
 var values = Ext.getCmp('form').getValues();
                 console.log("inside onNewNote function");

       Ext.Ajax.request({
                        url: 'http://call.com/the_webservice',
                        params : values,

                        failure: function (response) {
                        var text = response.responseText;
                         console.log("fail");

                        },                              success: function (response) {
                        var text = response.responseText;
                         console.log("success");

                        }

                        });



                  }

                  // init and launch functions omitted.
                  });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T13:32:02+00:00Added an answer on June 3, 2026 at 1:32 pm

    1.) In my code, i can only display the JSON response from the VIEW, but how can i send it to the COntroller ?

    Why you want to pass the values back to the view from the controller?

    I don’t see any valid reason to do so.

    You can show the Ext.Msg.alert in the controller itself on success and failure of Web Service like this,

    .....
    .....
    url: 'http://call.com/the_webservice',
    params : values,
    
    failure: function (response) {
       var text = response.responseText;
       Ext.Msg.alert('Error','Error while executing Web Service');
    },
    
    success: function (response) {
       var text = response.responseText;
       Ext.Msg.alert('Success','Web Service code successfully executed');
    },
    .....
    .....
    

    2) How could i, separate the string from the view, and only get the
    SUCCESS or FAIL string from the JSON response ?

    EDIT:

    Do something like this ..

    var result = Ext.decode(response.responseText);
    
    // result.value = SUCCESS or FAIL
    Ext.Msg.alert('Message',result.value);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hi i have a NSTableView in a view controller class i have added an
I have added a Button in the View { xtype:'button', id:'when_button_click', text:'Button Click', ui:'alert'
I have an activity view that I have added in AppDelegate class to tap
I have added the COleDropTarget variable to my view class and registered it in
I already have a view controller with a default view and few things added
I have a root view controller which has few buttons. On click of these
I want to display PickerView when I click the button. I have a view
In my custom View which I have added to my viewControllers's view, I need
I have added a UILabel to my view programmatically like this: myLabel = [[UILabel
I am using a storyboard and I have added iAd banner to my view.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.