Attempting to display Json result but getting only [Object,Object] [duplicate]











up vote
0
down vote

favorite













This question already has an answer here:




  • How can I view an object with an alert()

    9 answers




I am fetching one row from database in Object format.



here is my .cs code



public JsonResult GetApplicationDetail(string id){
sp_Application_Result AppObj = new sp_Application_Result();
ObjectResult obj = db.sp_Application(id);
foreach (sp_Application_Result i in obj){
AppObj = i;
}
return Json(AppObj, JsonRequestBehavior.AllowGet);
}


and here is my script code



$.ajax({
type: "GET",
url: "/Application/GetApplicationDetail/",
datatype: "json",
data: {"id" : name} ,
success: function (response) {
alert(response);
}
);


when I'm trying to show response, it's showing [Object,object]



I am not getting how to show response result, actually I want to store response data into table.










share|improve this question















marked as duplicate by Quentin ajax
Users with the  ajax badge can single-handedly close ajax questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 15 at 13:54


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 1




    display in console.log
    – Jax Teller
    Nov 15 at 13:53










  • only console.log(response) can expand and print objects, instead alert can only print/display strings so either use console.log or JSON.stringify(response) before alert
    – Nikos M.
    Nov 15 at 13:53










  • Either you can log the response directly using console.log(response) or you can transform the json object to string to be able to display it in the alert alert(JSON.stringify(response))
    – Karim
    Nov 15 at 13:55












  • Try to console your response. console.log(response), then see what you are getting there
    – Sajjad Ali
    Nov 15 at 13:55










  • hey... Try to console.log() your response? xD
    – Stender
    Nov 15 at 14:07















up vote
0
down vote

favorite













This question already has an answer here:




  • How can I view an object with an alert()

    9 answers




I am fetching one row from database in Object format.



here is my .cs code



public JsonResult GetApplicationDetail(string id){
sp_Application_Result AppObj = new sp_Application_Result();
ObjectResult obj = db.sp_Application(id);
foreach (sp_Application_Result i in obj){
AppObj = i;
}
return Json(AppObj, JsonRequestBehavior.AllowGet);
}


and here is my script code



$.ajax({
type: "GET",
url: "/Application/GetApplicationDetail/",
datatype: "json",
data: {"id" : name} ,
success: function (response) {
alert(response);
}
);


when I'm trying to show response, it's showing [Object,object]



I am not getting how to show response result, actually I want to store response data into table.










share|improve this question















marked as duplicate by Quentin ajax
Users with the  ajax badge can single-handedly close ajax questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 15 at 13:54


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 1




    display in console.log
    – Jax Teller
    Nov 15 at 13:53










  • only console.log(response) can expand and print objects, instead alert can only print/display strings so either use console.log or JSON.stringify(response) before alert
    – Nikos M.
    Nov 15 at 13:53










  • Either you can log the response directly using console.log(response) or you can transform the json object to string to be able to display it in the alert alert(JSON.stringify(response))
    – Karim
    Nov 15 at 13:55












  • Try to console your response. console.log(response), then see what you are getting there
    – Sajjad Ali
    Nov 15 at 13:55










  • hey... Try to console.log() your response? xD
    – Stender
    Nov 15 at 14:07













up vote
0
down vote

favorite









up vote
0
down vote

favorite












This question already has an answer here:




  • How can I view an object with an alert()

    9 answers




I am fetching one row from database in Object format.



here is my .cs code



public JsonResult GetApplicationDetail(string id){
sp_Application_Result AppObj = new sp_Application_Result();
ObjectResult obj = db.sp_Application(id);
foreach (sp_Application_Result i in obj){
AppObj = i;
}
return Json(AppObj, JsonRequestBehavior.AllowGet);
}


and here is my script code



$.ajax({
type: "GET",
url: "/Application/GetApplicationDetail/",
datatype: "json",
data: {"id" : name} ,
success: function (response) {
alert(response);
}
);


when I'm trying to show response, it's showing [Object,object]



I am not getting how to show response result, actually I want to store response data into table.










share|improve this question
















This question already has an answer here:




  • How can I view an object with an alert()

    9 answers




I am fetching one row from database in Object format.



here is my .cs code



public JsonResult GetApplicationDetail(string id){
sp_Application_Result AppObj = new sp_Application_Result();
ObjectResult obj = db.sp_Application(id);
foreach (sp_Application_Result i in obj){
AppObj = i;
}
return Json(AppObj, JsonRequestBehavior.AllowGet);
}


and here is my script code



$.ajax({
type: "GET",
url: "/Application/GetApplicationDetail/",
datatype: "json",
data: {"id" : name} ,
success: function (response) {
alert(response);
}
);


when I'm trying to show response, it's showing [Object,object]



I am not getting how to show response result, actually I want to store response data into table.





This question already has an answer here:




  • How can I view an object with an alert()

    9 answers








javascript jquery html json ajax






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 at 14:59









executable

1,2081221




1,2081221










asked Nov 15 at 13:50









mohd sarfaraz

84




84




marked as duplicate by Quentin ajax
Users with the  ajax badge can single-handedly close ajax questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 15 at 13:54


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by Quentin ajax
Users with the  ajax badge can single-handedly close ajax questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 15 at 13:54


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 1




    display in console.log
    – Jax Teller
    Nov 15 at 13:53










  • only console.log(response) can expand and print objects, instead alert can only print/display strings so either use console.log or JSON.stringify(response) before alert
    – Nikos M.
    Nov 15 at 13:53










  • Either you can log the response directly using console.log(response) or you can transform the json object to string to be able to display it in the alert alert(JSON.stringify(response))
    – Karim
    Nov 15 at 13:55












  • Try to console your response. console.log(response), then see what you are getting there
    – Sajjad Ali
    Nov 15 at 13:55










  • hey... Try to console.log() your response? xD
    – Stender
    Nov 15 at 14:07














  • 1




    display in console.log
    – Jax Teller
    Nov 15 at 13:53










  • only console.log(response) can expand and print objects, instead alert can only print/display strings so either use console.log or JSON.stringify(response) before alert
    – Nikos M.
    Nov 15 at 13:53










  • Either you can log the response directly using console.log(response) or you can transform the json object to string to be able to display it in the alert alert(JSON.stringify(response))
    – Karim
    Nov 15 at 13:55












  • Try to console your response. console.log(response), then see what you are getting there
    – Sajjad Ali
    Nov 15 at 13:55










  • hey... Try to console.log() your response? xD
    – Stender
    Nov 15 at 14:07








1




1




display in console.log
– Jax Teller
Nov 15 at 13:53




display in console.log
– Jax Teller
Nov 15 at 13:53












only console.log(response) can expand and print objects, instead alert can only print/display strings so either use console.log or JSON.stringify(response) before alert
– Nikos M.
Nov 15 at 13:53




only console.log(response) can expand and print objects, instead alert can only print/display strings so either use console.log or JSON.stringify(response) before alert
– Nikos M.
Nov 15 at 13:53












Either you can log the response directly using console.log(response) or you can transform the json object to string to be able to display it in the alert alert(JSON.stringify(response))
– Karim
Nov 15 at 13:55






Either you can log the response directly using console.log(response) or you can transform the json object to string to be able to display it in the alert alert(JSON.stringify(response))
– Karim
Nov 15 at 13:55














Try to console your response. console.log(response), then see what you are getting there
– Sajjad Ali
Nov 15 at 13:55




Try to console your response. console.log(response), then see what you are getting there
– Sajjad Ali
Nov 15 at 13:55












hey... Try to console.log() your response? xD
– Stender
Nov 15 at 14:07




hey... Try to console.log() your response? xD
– Stender
Nov 15 at 14:07












1 Answer
1






active

oldest

votes

















up vote
3
down vote













Let's try with



JSON.stringify it will convert the object response to string



alert(JSON.stringify(response));






share|improve this answer





















  • Thanks Tai Le, already tried with this solution, but not able to store that result in Table.
    – mohd sarfaraz
    Nov 15 at 13:54










  • hmm. which table?
    – Tai Le
    Nov 15 at 13:57










  • I have used in view <table id="datatable"> </table> so, i want to store json response in this table. Tai Le can you please help.
    – mohd sarfaraz
    Nov 15 at 14:00










  • I found some answers here: stackoverflow.com/questions/17724017/…
    – Tai Le
    Nov 15 at 14:03










  • @mohdsarfaraz that's really a totally separate issue to the problem you illustrated in the question. It's unrelated and is a different task you need to complete. Don't be a help vampire. Instead, if you have a new problem and can't solve it by your own research and coding, then ask a new question.
    – ADyson
    Nov 15 at 14:06




















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
3
down vote













Let's try with



JSON.stringify it will convert the object response to string



alert(JSON.stringify(response));






share|improve this answer





















  • Thanks Tai Le, already tried with this solution, but not able to store that result in Table.
    – mohd sarfaraz
    Nov 15 at 13:54










  • hmm. which table?
    – Tai Le
    Nov 15 at 13:57










  • I have used in view <table id="datatable"> </table> so, i want to store json response in this table. Tai Le can you please help.
    – mohd sarfaraz
    Nov 15 at 14:00










  • I found some answers here: stackoverflow.com/questions/17724017/…
    – Tai Le
    Nov 15 at 14:03










  • @mohdsarfaraz that's really a totally separate issue to the problem you illustrated in the question. It's unrelated and is a different task you need to complete. Don't be a help vampire. Instead, if you have a new problem and can't solve it by your own research and coding, then ask a new question.
    – ADyson
    Nov 15 at 14:06

















up vote
3
down vote













Let's try with



JSON.stringify it will convert the object response to string



alert(JSON.stringify(response));






share|improve this answer





















  • Thanks Tai Le, already tried with this solution, but not able to store that result in Table.
    – mohd sarfaraz
    Nov 15 at 13:54










  • hmm. which table?
    – Tai Le
    Nov 15 at 13:57










  • I have used in view <table id="datatable"> </table> so, i want to store json response in this table. Tai Le can you please help.
    – mohd sarfaraz
    Nov 15 at 14:00










  • I found some answers here: stackoverflow.com/questions/17724017/…
    – Tai Le
    Nov 15 at 14:03










  • @mohdsarfaraz that's really a totally separate issue to the problem you illustrated in the question. It's unrelated and is a different task you need to complete. Don't be a help vampire. Instead, if you have a new problem and can't solve it by your own research and coding, then ask a new question.
    – ADyson
    Nov 15 at 14:06















up vote
3
down vote










up vote
3
down vote









Let's try with



JSON.stringify it will convert the object response to string



alert(JSON.stringify(response));






share|improve this answer












Let's try with



JSON.stringify it will convert the object response to string



alert(JSON.stringify(response));







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 15 at 13:51









Tai Le

1,491618




1,491618












  • Thanks Tai Le, already tried with this solution, but not able to store that result in Table.
    – mohd sarfaraz
    Nov 15 at 13:54










  • hmm. which table?
    – Tai Le
    Nov 15 at 13:57










  • I have used in view <table id="datatable"> </table> so, i want to store json response in this table. Tai Le can you please help.
    – mohd sarfaraz
    Nov 15 at 14:00










  • I found some answers here: stackoverflow.com/questions/17724017/…
    – Tai Le
    Nov 15 at 14:03










  • @mohdsarfaraz that's really a totally separate issue to the problem you illustrated in the question. It's unrelated and is a different task you need to complete. Don't be a help vampire. Instead, if you have a new problem and can't solve it by your own research and coding, then ask a new question.
    – ADyson
    Nov 15 at 14:06




















  • Thanks Tai Le, already tried with this solution, but not able to store that result in Table.
    – mohd sarfaraz
    Nov 15 at 13:54










  • hmm. which table?
    – Tai Le
    Nov 15 at 13:57










  • I have used in view <table id="datatable"> </table> so, i want to store json response in this table. Tai Le can you please help.
    – mohd sarfaraz
    Nov 15 at 14:00










  • I found some answers here: stackoverflow.com/questions/17724017/…
    – Tai Le
    Nov 15 at 14:03










  • @mohdsarfaraz that's really a totally separate issue to the problem you illustrated in the question. It's unrelated and is a different task you need to complete. Don't be a help vampire. Instead, if you have a new problem and can't solve it by your own research and coding, then ask a new question.
    – ADyson
    Nov 15 at 14:06


















Thanks Tai Le, already tried with this solution, but not able to store that result in Table.
– mohd sarfaraz
Nov 15 at 13:54




Thanks Tai Le, already tried with this solution, but not able to store that result in Table.
– mohd sarfaraz
Nov 15 at 13:54












hmm. which table?
– Tai Le
Nov 15 at 13:57




hmm. which table?
– Tai Le
Nov 15 at 13:57












I have used in view <table id="datatable"> </table> so, i want to store json response in this table. Tai Le can you please help.
– mohd sarfaraz
Nov 15 at 14:00




I have used in view <table id="datatable"> </table> so, i want to store json response in this table. Tai Le can you please help.
– mohd sarfaraz
Nov 15 at 14:00












I found some answers here: stackoverflow.com/questions/17724017/…
– Tai Le
Nov 15 at 14:03




I found some answers here: stackoverflow.com/questions/17724017/…
– Tai Le
Nov 15 at 14:03












@mohdsarfaraz that's really a totally separate issue to the problem you illustrated in the question. It's unrelated and is a different task you need to complete. Don't be a help vampire. Instead, if you have a new problem and can't solve it by your own research and coding, then ask a new question.
– ADyson
Nov 15 at 14:06






@mohdsarfaraz that's really a totally separate issue to the problem you illustrated in the question. It's unrelated and is a different task you need to complete. Don't be a help vampire. Instead, if you have a new problem and can't solve it by your own research and coding, then ask a new question.
– ADyson
Nov 15 at 14:06





Popular posts from this blog

Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

ComboBox Display Member on multiple fields

Is it possible to collect Nectar points via Trainline?