Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

one more beginner level question

$
0
0

I got the ajax response working as hoped, I returned a List<MyClass> and I can see when I push F12 I am getting actual data back in JSON form.

However, I don't know how to turn it back from Json into a class again.

I am trying this, just as test code, and it does not work.

WHere it falls apart is at the var bead = parseJSON(asObjects[i]); 

and I don't know what I should be doing at this point.

Could someone please point me to the next step on turning my class that had been sent as JsonResult, back into a class?

function loadDoc() {
            var xhttp = new XMLHttpRequest();
            xhttp.onreadystatechange = function () {
                if (this.readyState == 4 && this.status == 200 ) {
                    var json = this.response;
                    var asObjects = jQuery.parseJSON(json);                    
                    var result = "";
                    var i;
                    for (i = 0; i < 10;i++)
                    {
                        var bead = parseJSON(asObjects[i]);
                        result += bead[0];

                    document.getElementById("demo").innerHTML = result;
                }
            };
            xhttp.open("GET", "/_ajax/?handler=Filter",true);
            xhttp.send();
        }


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>