---
title: "Html with json mvc"  
description: "Html with json mvc"  
author: "Anonymous User"  
published: 2014-10-29  
updated: 2014-10-29  
canonical: https://www.mindstick.com/forum/2459/html-with-json-mvc  
category: "asp.net mvc"  
tags: ["html", "json", "mvc4"]  
reading_time: 1 minute  

---

# Html with json mvc

I need to pass [html](https://www.mindstick.com/articles/1530/design-a-simple-stylish-calculator-using-html-css-and-javascript) as [parameter](https://www.mindstick.com/blog/450/parameter-class-in-c-sharp) using [json](https://www.mindstick.com/forum/34446/convert-json-string-to-object) [asp.net](https://www.mindstick.com/articles/934/default-folders-available-inside-the-asp-dot-net-application-folder) mvc2

I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to do like this:

```
$.ajax({        type: "POST",        dataType: "json",        contentType: 'application/json; charset=utf-8',        url: "/DefaultView/GeneratePDF",        data: { "pdf": JSON.parse($("#displayContainer").html()) },        success: function (data) {            //nothing here        }    });
```

but it throws the "Uncaught [SyntaxError](https://www.mindstick.com/forum/159404/a-database-query-returns-a-syntaxerror): [Unexpected token](https://www.mindstick.com/forum/34353/error-messagesystem-queryexception-unexpected-token) < " error.

using stringify() I [am getting](https://www.mindstick.com/forum/34179/i-am-getting-error-while-assigning-the-data-to-the-array-list) null here:

```
[HttpPost]    [ValidateInput(false)]     public virtual ActionResult GeneratePDF(string pdf)    {        pdf <---    }
```

## Replies

### Reply by Anonymous User

**Use the stringify method of JSON:**

```
$.ajax({        type: "POST",        dataType: "json",        contentType: 'application/json; charset=utf-8',        url: "/DefaultView/GeneratePDF",        data: { "pdf": JSON.stringify($("#displayContainer").html()) }, //change
to stringify        success: function (data) {            //nothing
here        }    });
```


---

Original Source: https://www.mindstick.com/forum/2459/html-with-json-mvc

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
