我可以像这样发送html的值$("#id").html()给后面的代码吗?

Can I send the value of html like this $("#id").html() to code behind?

本文关键字:quot html 代码 像这样 我可以 #id 的值      更新时间:2023-09-26

我已经尝试过它通过ajax,但它不工作,所以请帮助我!!!!!!我试着在cookie中输入但是在后面的代码中没有看到

var datah = $(“#currid”).html()
var data = {
  id: currid,
  html: datah
 };

$.ajax({
   type: "POST",
   url: url,
   data: data,
   success: function(msg){
     alert( "return back" );
   }
 });

试试这个

在传输之前必须对html内容进行编码。您可以在java脚本中使用escape。你可以从服务器

解码回来
 var encodedData= escape($(“#id”).html()) ;
    var postData = { htmlData:encodedData};    
     $.ajax({
       type: "POST",
       url: url,
       data: postData,
       success: function(msg){
         // do your operation
         }
     });