javascript - How to pass content of html with ajax (MVC) -


i need html specific form , save in html file in project.

so have builder ajax function sending html server , saving it.

i have problem send html server, if send string "hello word" , working "<p>hello</p>" not working.

what right way send html content ajax?

i know [validateinput(false)] not working

this controller:

 [httpget]  [validateinput(false)]  public void updatehtml(string html)      {         try          {              string path1 = @"d:\test\my.html";              system.io.file.writealltext(path1, html);                  }                 catch (exception ex)                 {                 }              } 

this ajax:

function btn_upload_click() {      var html = tinymce.activeeditor.getcontent();//my html   //var html = "hello"//like working     var token = $('input[name="__requestverificationtoken"]').val();//checked:ok     var funcurl = $("#btn_savehtml").data("urlaction");//checked :ok     $.ajax({         url: funcurl,         type: 'get',         datatype : "text/xml",         data: {             html:html,             __requestverificationtoken: token         },          success: function (data)         {             alert("good");         },         error: function (xhr, status, error) {              alert(xhr.responsetext);             alert(xhr.status);             alert(error);         }     });  } 

update2: html trying send:

"<p style=\"text-align: center; font-size: 15px;\"><img title=\"tinymce logo\" src=\"//www.tinymce.com/images/glyph-tinymce@2x.png\" alt=\"tinymce logo\" width=\"110\" height=\"97\" /></p>\n<h1 style=\"text-align: center;\">welcome tinymce editor demo!</h1>\n<h1><img style=\"float: right; padding: 0 0 10px 10px;\" title=\"tiny husky\" src=\"//www.tinymce.com/docs/images/tiny-husky.jpg\" alt=\"tiny husky\" width=\"304\" height=\"320\" /></h1>\n<h2>image tools plugin feature<br />click on image started</h2>\n<p>please try out features provided in image tools example.</p>\n<p>note <strong>moxiemanager</strong> file , image management functionality in example part of our commercial offering &ndash; demo show integration.</p>\n<h2>got questions or need help?</h2>\n<ul>\n<li>our <a href=\"https://www.tinymce.com/docs/\">documentation</a> great resource learning how configure tinymce.</li>\n<li>have specific question? visit <a href=\"http://community.tinymce.com/forum/\">community forum</a>.</li>\n<li>we offer enterprise grade support part of <a href=\"www.tinymce.com/pricing\">tinymce enterprise</a>.</li>\n</ul>\n<h2>a simple table play with</h2>\n<table>\n<thead>\n<tr>\n<th>product</th>\n<th>cost</th>\n<th>really?</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>tinymce</td>\n<td>free</td>\n<td>yes!</td>\n</tr>\n<tr>\n<td>plupload</td>\n<td>free</td>\n<td>yes!</td>\n</tr>\n</tbody>\n</table>\n<h2>found bug?</h2>\n<p>if think have found bug please create issue on <a href=\"https://github.com/tinymce/tinymce/issues\">github repo</a> report developers.</p>\n<h2>finally ...</h2>\n<p>don't forget check out our other product <a href=\"http://www.plupload.com\" target=\"_blank\">plupload</a>, ultimate upload solution featuring html5 upload support.</p>\n<p>thanks supporting tinymce! hope helps , users create great content.<br />all best tinymce team.</p>"

my ajax return empty error, can't more information.

this ajax request

$.ajax({         url: '@url.action("test")',         type: 'post',         datatype: 'text/xml',         data: { "html": "<p style=\"text-align: center; font-size: 15px;\"><img title=\"tinymce logo\" src=\"//www.tinymce.com/images/glyph-tinymce@2x.png\" alt=\"tinymce logo\" width=\"110\" height=\"97\" /></p>\n<h1 style=\"text-align: center;\">welcome tinymce editor demo!</h1>\n<h1><img style=\"float: right; padding: 0 0 10px 10px;\" title=\"tiny husky\" src=\"//www.tinymce.com/docs/images/tiny-husky.jpg\" alt=\"tiny husky\" width=\"304\" height=\"320\" /></h1>\n<h2>image tools plugin feature<br />click on image started</h2>\n<p>please try out features provided in image tools example.</p>\n<p>note <strong>moxiemanager</strong> file , image management functionality in example part of our commercial offering &ndash; demo show integration.</p>\n<h2>got questions or need help?</h2>\n<ul>\n<li>our <a href=\"https://www.tinymce.com/docs/\">documentation</a> great resource learning how configure tinymce.</li>\n<li>have specific question? visit <a href=\"http://community.tinymce.com/forum/\">community forum</a>.</li>\n<li>we offer enterprise grade support part of <a href=\"www.tinymce.com/pricing\">tinymce enterprise</a>.</li>\n</ul>\n<h2>a simple table play with</h2>\n<table>\n<thead>\n<tr>\n<th>product</th>\n<th>cost</th>\n<th>really?</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>tinymce</td>\n<td>free</td>\n<td>yes!</td>\n</tr>\n<tr>\n<td>plupload</td>\n<td>free</td>\n<td>yes!</td>\n</tr>\n</tbody>\n</table>\n<h2>found bug?</h2>\n<p>if think have found bug please create issue on <a href=\"https://github.com/tinymce/tinymce/issues\">github repo</a> report developers.</p>\n<h2>finally ...</h2>\n<p>don't forget check out our other product <a href=\"http://www.plupload.com\" target=\"_blank\">plupload</a>, ultimate upload solution featuring html5 upload support.</p>\n<p>thanks supporting tinymce! hope helps , users create great content.<br />all best tinymce team.</p>" },         error: function () {             console.log("error");         },         success: function () {          }     }) 

and server code

    [httppost]     [validateinput(false)]     public void test(string html)     {      } 

of course dont have token.i can catch html server in debug mode.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -