I am faced with the task of transferring values from a C# class to a JavaScript file. To achieve this, I have generated a string in C# which contains the values of the list as follows:
count = 0;
JString = "[";
for(i=0; i<x; i++)
{
JString += "{Source:" + A[i] + ", Number:" + 3 + ", Target:" + B[i] + "},";
count++;
}
JString = JString.Remove(JString.Length - 1, 1); //to eliminate the last ,
JString += "]";
GraphData.Text = "" + "var JString =" + JString + " ;" + "var count =" + count + " ;";
The GraphData label is utilized to store the created string.
In the JavaScript file, an attempt was made to retrieve the sent string using the following code snippet:
$("#GraphData").val(); //to get the string sent
However, it seems like this approach is not functioning correctly. Could there be something wrong with how I'm implementing it?
I appreciate any insights or guidance on this matter. Thank you in advance :)