Home Show Model Information In mvc view using handlebars
Reply: 0

Show Model Information In mvc view using handlebars

user2375 Published in July 16, 2018, 6:39 am

Show model information in mvc view, i am new to handle bars. I want to show the information of the model using handlebars.

I have a Ajax call which return a model information on success i want to bind the template with the data.

However, i am not getting success.

My Effort is below.

<html lang="en">

    <script src="~/scripts/jquery-1.10.2.min.js"></script>
    <script src="~/scripts/handlebars.min.js"></script>

    <title> HandleBar Practice</title>

    <script id="message-response-template" type="text/x-handlebars-template">

            My FirstName Is: {{FirstName}}
            My MiddleName Is: {{MiddleName}}
            My Address Is: {{Address}}
            My PhoneNumber Is: {{PhoneNumber}}
            My CNIC Is: {{CNIC}}

    $(document).ready(function () {
        alert('document ready');
            type: "POST",
            url: "AjaxCall",
            data: '{ sendData: "ok" }',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (result) {
                var templateResponse = Handlebars.compile($("#message-response-template").html());



Browser Console

ƒ e(a,b){return g||(g=d()),g.call(this,a,b)}

var templateResponse = Handlebars.compile($("#message-response-template").html());

undefined //it display undefined i am not getting the idea what's wrong


        public ActionResult AjaxCall(string sendData)

            return Json(new Employee() { FirstName = "John", MiddleName = "N/A", LastName = "DOE", CNIC = "123234234", Address = "Pakistan" }, JsonRequestBehavior.AllowGet);
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.347476 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO