How to get value/data of each element of ListReturn View as String in .NET CoreHow do I detect a click outside an element?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I check if an array includes an object in JavaScript?How to get the children of the $(this) selector?How do I correctly clone a JavaScript object?How can I get query string values in JavaScript?How to check if an object is an array?How do I remove a particular element from an array in JavaScript?
Could IPv6 make NAT / port numbers redundant?
Change TeXForm of ArcTan
Is American Express widely accepted in France?
Double integral bounds of integration polar change of coordinate
The oldest tradition stopped before it got back to him
Creating Fictional Slavic Place Names
Since Angular 8 uses @ViewChild, the new static option, how should I use it?
Singlequote and backslash
Rotated Position of Integers
When was the word "ambigu" first used with the sense of "meal with all items served at the same time"?
Can you use a concentration spell while using Mantle of Majesty?
Self-Preservation: How to DM NPCs that Love Living?
Where can I find the list of all tendons in the human body?
What does the behaviour of water on the skin of an aircraft in flight tell us?
Strange math syntax in old basic listing
What does it mean by "d-ism of Leibniz" and "dotage of Newton" in simple English?
Term for checking piece whose opponent daren't capture it
California: "For quality assurance, this phone call is being recorded"
Humans meet a distant alien species. How do they standardize? - Units of Measure
Explain Ant-Man's "not it" scene from Avengers: Endgame
What is the intuition behind uniform continuity?
Scala list with same adjacent values
Are there regional foods in Westeros?
Asking bank to reduce APR instead of increasing credit limit
How to get value/data of each element of List
Return View as String in .NET CoreHow do I detect a click outside an element?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I check if an array includes an object in JavaScript?How to get the children of the $(this) selector?How do I correctly clone a JavaScript object?How can I get query string values in JavaScript?How to check if an object is an array?How do I remove a particular element from an array in JavaScript?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
How to get value of Object from List in jQuery? Ath the moment I'm getting List of ActionResults from controller and I want to get value of each action (html code).
There is't a problem when I try to send single ActionResult - without list.
When I try to send List<ActionResult>
I get object Object
every time.
<script type="text/javascript">
$(document).on('click', 'button', function ()
$cartAction = $("#" + this.id);
var url = $cartAction.data("url");
$.get(url, function (actions)
console.log(actions); <-- return Objects Array
console.log(???); <-- how to get value of each actions
console.log(actions[1]); <-- return a single object
console.log(actions[1].document) <-- value undefined
);
);
</script>
public ActionResult Index()
var actionList = new List<ActionResult>()
// ViewComponents, PartialViews
;
return Json(actionList);
I expect return html code for each ActionResult, but I get
[object Object],[object Object]
for actions list.
Edit: Answer on my question is here stackoverflow.com/a/53639387/10338470
javascript jquery asp.net-core
|
show 5 more comments
How to get value of Object from List in jQuery? Ath the moment I'm getting List of ActionResults from controller and I want to get value of each action (html code).
There is't a problem when I try to send single ActionResult - without list.
When I try to send List<ActionResult>
I get object Object
every time.
<script type="text/javascript">
$(document).on('click', 'button', function ()
$cartAction = $("#" + this.id);
var url = $cartAction.data("url");
$.get(url, function (actions)
console.log(actions); <-- return Objects Array
console.log(???); <-- how to get value of each actions
console.log(actions[1]); <-- return a single object
console.log(actions[1].document) <-- value undefined
);
);
</script>
public ActionResult Index()
var actionList = new List<ActionResult>()
// ViewComponents, PartialViews
;
return Json(actionList);
I expect return html code for each ActionResult, but I get
[object Object],[object Object]
for actions list.
Edit: Answer on my question is here stackoverflow.com/a/53639387/10338470
javascript jquery asp.net-core
1
Loop over theactions
array. Don't usealert
for debugging. Log to console and you will see exactly what you are working with
– charlietfl
Mar 24 at 11:09
Do not returnList<ActionResult>
from action. ReturnActionResult
and at the end of method callreturn Json(collection)
. In js browse object properties
– Alexander
Mar 24 at 11:10
After change on Json(collection) result is the same - undefined value
– Kapker
Mar 24 at 11:50
Maybe there's no document key in index 1? Doesactions.forEach(action => console.dir(action);)
gives you any results?
– eyecatchUp
Mar 24 at 12:25
I tried foreach loop and for every elements of list I getObject
in console, but I want to get value thisObject
(html code)
– Kapker
Mar 24 at 12:30
|
show 5 more comments
How to get value of Object from List in jQuery? Ath the moment I'm getting List of ActionResults from controller and I want to get value of each action (html code).
There is't a problem when I try to send single ActionResult - without list.
When I try to send List<ActionResult>
I get object Object
every time.
<script type="text/javascript">
$(document).on('click', 'button', function ()
$cartAction = $("#" + this.id);
var url = $cartAction.data("url");
$.get(url, function (actions)
console.log(actions); <-- return Objects Array
console.log(???); <-- how to get value of each actions
console.log(actions[1]); <-- return a single object
console.log(actions[1].document) <-- value undefined
);
);
</script>
public ActionResult Index()
var actionList = new List<ActionResult>()
// ViewComponents, PartialViews
;
return Json(actionList);
I expect return html code for each ActionResult, but I get
[object Object],[object Object]
for actions list.
Edit: Answer on my question is here stackoverflow.com/a/53639387/10338470
javascript jquery asp.net-core
How to get value of Object from List in jQuery? Ath the moment I'm getting List of ActionResults from controller and I want to get value of each action (html code).
There is't a problem when I try to send single ActionResult - without list.
When I try to send List<ActionResult>
I get object Object
every time.
<script type="text/javascript">
$(document).on('click', 'button', function ()
$cartAction = $("#" + this.id);
var url = $cartAction.data("url");
$.get(url, function (actions)
console.log(actions); <-- return Objects Array
console.log(???); <-- how to get value of each actions
console.log(actions[1]); <-- return a single object
console.log(actions[1].document) <-- value undefined
);
);
</script>
public ActionResult Index()
var actionList = new List<ActionResult>()
// ViewComponents, PartialViews
;
return Json(actionList);
I expect return html code for each ActionResult, but I get
[object Object],[object Object]
for actions list.
Edit: Answer on my question is here stackoverflow.com/a/53639387/10338470
javascript jquery asp.net-core
javascript jquery asp.net-core
edited Mar 24 at 18:02
Kapker
asked Mar 24 at 11:05
KapkerKapker
34
34
1
Loop over theactions
array. Don't usealert
for debugging. Log to console and you will see exactly what you are working with
– charlietfl
Mar 24 at 11:09
Do not returnList<ActionResult>
from action. ReturnActionResult
and at the end of method callreturn Json(collection)
. In js browse object properties
– Alexander
Mar 24 at 11:10
After change on Json(collection) result is the same - undefined value
– Kapker
Mar 24 at 11:50
Maybe there's no document key in index 1? Doesactions.forEach(action => console.dir(action);)
gives you any results?
– eyecatchUp
Mar 24 at 12:25
I tried foreach loop and for every elements of list I getObject
in console, but I want to get value thisObject
(html code)
– Kapker
Mar 24 at 12:30
|
show 5 more comments
1
Loop over theactions
array. Don't usealert
for debugging. Log to console and you will see exactly what you are working with
– charlietfl
Mar 24 at 11:09
Do not returnList<ActionResult>
from action. ReturnActionResult
and at the end of method callreturn Json(collection)
. In js browse object properties
– Alexander
Mar 24 at 11:10
After change on Json(collection) result is the same - undefined value
– Kapker
Mar 24 at 11:50
Maybe there's no document key in index 1? Doesactions.forEach(action => console.dir(action);)
gives you any results?
– eyecatchUp
Mar 24 at 12:25
I tried foreach loop and for every elements of list I getObject
in console, but I want to get value thisObject
(html code)
– Kapker
Mar 24 at 12:30
1
1
Loop over the
actions
array. Don't use alert
for debugging. Log to console and you will see exactly what you are working with– charlietfl
Mar 24 at 11:09
Loop over the
actions
array. Don't use alert
for debugging. Log to console and you will see exactly what you are working with– charlietfl
Mar 24 at 11:09
Do not return
List<ActionResult>
from action. Return ActionResult
and at the end of method call return Json(collection)
. In js browse object properties– Alexander
Mar 24 at 11:10
Do not return
List<ActionResult>
from action. Return ActionResult
and at the end of method call return Json(collection)
. In js browse object properties– Alexander
Mar 24 at 11:10
After change on Json(collection) result is the same - undefined value
– Kapker
Mar 24 at 11:50
After change on Json(collection) result is the same - undefined value
– Kapker
Mar 24 at 11:50
Maybe there's no document key in index 1? Does
actions.forEach(action => console.dir(action);)
gives you any results?– eyecatchUp
Mar 24 at 12:25
Maybe there's no document key in index 1? Does
actions.forEach(action => console.dir(action);)
gives you any results?– eyecatchUp
Mar 24 at 12:25
I tried foreach loop and for every elements of list I get
Object
in console, but I want to get value this Object
(html code)– Kapker
Mar 24 at 12:30
I tried foreach loop and for every elements of list I get
Object
in console, but I want to get value this Object
(html code)– Kapker
Mar 24 at 12:30
|
show 5 more comments
1 Answer
1
active
oldest
votes
In jQuery you can iterate through the Values like this
<script type="text/javascript">
$(document).on('click', 'button', function ()
$cartAction = $("#" + this.id);
var url = $cartAction.data("url");
$.get(url, function (actions)
console.log(actions); // <-- return Objects Array
$.each(function() // <-- iterates through each object in actions array
console.log($(this)); // <-- logs the object to the console
);
console.log(actions[1]); // <-- return a single object
console.log(actions[1].document) // <-- value undefined
);
);
</script>
In most browsers even console.log(actions);
would work. But you can always JSON.stringify(actions);
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55323143%2fhow-to-get-value-data-of-each-element-of-listobject%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
In jQuery you can iterate through the Values like this
<script type="text/javascript">
$(document).on('click', 'button', function ()
$cartAction = $("#" + this.id);
var url = $cartAction.data("url");
$.get(url, function (actions)
console.log(actions); // <-- return Objects Array
$.each(function() // <-- iterates through each object in actions array
console.log($(this)); // <-- logs the object to the console
);
console.log(actions[1]); // <-- return a single object
console.log(actions[1].document) // <-- value undefined
);
);
</script>
In most browsers even console.log(actions);
would work. But you can always JSON.stringify(actions);
add a comment |
In jQuery you can iterate through the Values like this
<script type="text/javascript">
$(document).on('click', 'button', function ()
$cartAction = $("#" + this.id);
var url = $cartAction.data("url");
$.get(url, function (actions)
console.log(actions); // <-- return Objects Array
$.each(function() // <-- iterates through each object in actions array
console.log($(this)); // <-- logs the object to the console
);
console.log(actions[1]); // <-- return a single object
console.log(actions[1].document) // <-- value undefined
);
);
</script>
In most browsers even console.log(actions);
would work. But you can always JSON.stringify(actions);
add a comment |
In jQuery you can iterate through the Values like this
<script type="text/javascript">
$(document).on('click', 'button', function ()
$cartAction = $("#" + this.id);
var url = $cartAction.data("url");
$.get(url, function (actions)
console.log(actions); // <-- return Objects Array
$.each(function() // <-- iterates through each object in actions array
console.log($(this)); // <-- logs the object to the console
);
console.log(actions[1]); // <-- return a single object
console.log(actions[1].document) // <-- value undefined
);
);
</script>
In most browsers even console.log(actions);
would work. But you can always JSON.stringify(actions);
In jQuery you can iterate through the Values like this
<script type="text/javascript">
$(document).on('click', 'button', function ()
$cartAction = $("#" + this.id);
var url = $cartAction.data("url");
$.get(url, function (actions)
console.log(actions); // <-- return Objects Array
$.each(function() // <-- iterates through each object in actions array
console.log($(this)); // <-- logs the object to the console
);
console.log(actions[1]); // <-- return a single object
console.log(actions[1].document) // <-- value undefined
);
);
</script>
In most browsers even console.log(actions);
would work. But you can always JSON.stringify(actions);
answered Mar 24 at 17:07
Marius SteinbachMarius Steinbach
78113
78113
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55323143%2fhow-to-get-value-data-of-each-element-of-listobject%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Loop over the
actions
array. Don't usealert
for debugging. Log to console and you will see exactly what you are working with– charlietfl
Mar 24 at 11:09
Do not return
List<ActionResult>
from action. ReturnActionResult
and at the end of method callreturn Json(collection)
. In js browse object properties– Alexander
Mar 24 at 11:10
After change on Json(collection) result is the same - undefined value
– Kapker
Mar 24 at 11:50
Maybe there's no document key in index 1? Does
actions.forEach(action => console.dir(action);)
gives you any results?– eyecatchUp
Mar 24 at 12:25
I tried foreach loop and for every elements of list I get
Object
in console, but I want to get value thisObject
(html code)– Kapker
Mar 24 at 12:30