Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Json data\javascript

Posted on 2017-08-15
8
Low Priority
?
38 Views
Last Modified: 2017-08-15
Hi Guys,
I send json data from my server to the view in MVC project.

Here is the link I send as a json:
dataCell.textCell = "<a onmouseout='HideFlyOut()' ;="" class='theme_color' onmouseover='ShowFlyOut('" + encryptedRowPass + "') href=\documentviewer.aspx?" + encryptedValue + "'<i class='fa fa-paperclip fa-flip-horizontal fa-2x theme_color'></i></a>"

Open in new window



Now in my UI side I'm getting this data which is one row and parse it to json:

 var sendDataRowsToView = JSON.parse(datarows)

Open in new window


Then I"m trying to place this data into a <td> in my dom:

 tableBody.append('<td> + sendDataRowsToView + </td>')

Open in new window



I'm getting the data and all works fine but it doesn't bind it to the dom:

Like I'm expecting to see for exmaple:
<td><a></a></td> which bind all the link from the server, but for some reason I can't see this data in my dom.

what am I doing wrong?
0
Comment
Question by:Moti Mashiah
  • 4
  • 4
8 Comments
 
LVL 60

Expert Comment

by:Julian Hansen
ID: 42255422
It is not clear what you are doing - when you say

I send json data from my server to the view in MVC project.
How?

Now in my UI side I'm getting this data which is one row and parse it to json:
 var sendDataRowsToView = JSON.parse(datarows)

Open in new window

Where does datarows come from?
tableBody - where is this defined.

Can we see more code.
0
 
LVL 1

Author Comment

by:Moti Mashiah
ID: 42255559
Sorry, Julian.

I wasn't clear enough, so let me simplify things.

let's say I got data from my server that look like that:

Untitled.png
Now the array contains 3 item in each row so the first row is html that I'm trying to bind into the <td></td> in my table but it doesn't show

Let me know if anything else.
0
 
LVL 60

Expert Comment

by:Julian Hansen
ID: 42255573
let's say I got data from my server that look like that:
But how are you getting the data from the server? Are you making an AJAX request?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Author Comment

by:Moti Mashiah
ID: 42255582
I just call web Api.
The only thing I want to know is why I can't nest the first item which is  HTML like to the td element. It shows empty.
0
 
LVL 60

Accepted Solution

by:
Julian Hansen earned 1000 total points
ID: 42255931
We are trying to get there - the code for adding it is as you have it so we have to backtrack to where you are getting the data from - so far I have not seen anything that shows where the data is coming from.

I just call web Api.
Can we see where you call that.
0
 
LVL 1

Author Comment

by:Moti Mashiah
ID: 42255947
Hi Julian,
I solved the issue the string URL I built on the server side wasn't written right so that is why I couldn't see anything when it comes to JSON data.
I see the data in the array at 0, but still, when I was trying to place it in the HTML tag I didn't see anything as again the URL was broken.
I fixed the URL and now all working fine.

Sorry, but I don't understand why you were trying to figure out from where the data is coming from. As my question was how do I place the data into the dom, in my view, there is no need to know from where the data is coming from, and that is why I didn't emphasize this part. I also sent a screen shot of how my data looks like.

Thank you.
0
 
LVL 1

Author Closing Comment

by:Moti Mashiah
ID: 42255948
Thank you for help Julian.
0
 
LVL 60

Expert Comment

by:Julian Hansen
ID: 42256051
Sorry, but I don't understand why you were trying to figure out from where the data is coming from. As my question was how do I place the data into the dom, in my view, there is no need to know from where the data is coming from, and that is why I didn't emphasize this part

The reason was because your JavaScript code was correct - but it did not appear to be working. Therefore the logical assumption would be that it was because the data was incorrect. It was pointless trying to fix your front end code - as there was nothing wrong with it - to trace the actual problem we would need to go back to the source.

Anyway, I am glad you are sorted out.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The well known Cerber ransomware continues to spread this summer through spear phishing email campaigns targeting enterprises. Learn how it easily bypasses traditional defenses - and what you can do to protect your data.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question