Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Json data\javascript

Posted on 2017-08-15
8
Low Priority
?
29 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 59

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 59

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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 59

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 59

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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This article discusses how to create an extensible mechanism for linked drop downs.
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…

722 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