0

enter image description hereHi I am developing Angularjs application and getting some data from Web API. I am able to receive data. I can confirm this because i can see in fiddler and browser developer tool as well. Below is my code. I am returning data as json from web api. I am returning below object.

return Request.CreateResponse(HttpStatusCode.OK, obj);

Object obj contains some fields(data);

In browser i can see response as below.

{"ID":11,"project_id":1,"levels":1,"icon":1,"description":1,"summary":1,"output":1,"owner":1,"role":1,"objectives":1,"reporting":1,"performance_indicators":1,"success":0,"Created":"0001-01-01T00:00:00","Updated":"0001-01-01T00:00:00"}

This is my angular code.

var saveSubs = ProjectSetting_Service.AddProcessSettings(sub);
            saveSubs.then(function (data) {
                alert((data.data));
                alert((data.obj));
            }, function (error) {
            })

This is my service.js code

this.AddProcessSettings = function (sub) {

        $http.post('/api/NCT_ProcessSettings/', sub).success(function (response) { alert(response); });
    }

In alert i want to see response data. May i get some help? Any help would be appreciated. Thank you.

4
  • You misspelled alert. Should be console.log. Commented Feb 10, 2017 at 7:31
  • Have you tried just alerting data? It looks to me like data doesn't contain a property data Commented Feb 10, 2017 at 7:32
  • what do you see inside data? Commented Feb 10, 2017 at 7:34
  • I can see just [object object] in alert...But in response i can see. I will update the screenshot above Commented Feb 10, 2017 at 7:36

1 Answer 1

4

According your response, it does not have data in it,

just put the alert as,

var saveSubs = ProjectSetting_Service.AddProcessSettings(sub);
            saveSubs.then(function (data) {
                alert((data));
                alert((data.project_id));
            }, function (error) {
            })

UPDATE

Your services is not returning anything, just change the service response to return it,

then you can access the data like alert(data.data);

Sign up to request clarification or add additional context in comments.

5 Comments

for that you need to use the property that you want to see, use data.project_id and see
I have posted service.js above. Does it has any problem in returning data?
yes. i will share. My id 345 595 037 password f72w5x
send the password
password is f72w5x

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.