0

I'd love some help here :) I'm trying to read the array I have in the controller into a variable in the script and use it.. Can someone help me please?

I'm actually trying to make an array of the names of the recipes that I already have in another list This is what I have on the controller

Then I need this list to use it in HTML and therefore - This is what I have in the script

As you understand, it doesn't work for me (by the way, when I enter directly in the script like this: var NAME=["---","---"...] it does work..)

I'm new to the subject, so I'm getting very confused.

Thanks in advance

  • 1
    [Please do not upload images of code/errors when asking a question.](https://meta.stackoverflow.com/q/285551/8967612) – 41686d6564 stands w. Palestine Oct 18 '22 at 16:03
  • You're outputting a C# array into a JavaScript context: you need to serialize it to JSON first. You nearly had that in your commented-out code, but you needed an `@` before your `Html.Raw`. You may also find this answer helpful, particularly the last update: https://stackoverflow.com/a/4599403/120955 – StriplingWarrior Oct 18 '22 at 16:17

0 Answers0