简体   繁体   English

HTML在POST请求中丢失

[英]Html lost in POST request

I try to send an object, containing an object that contains raw html 我尝试发送一个对象,其中包含一个包含原始html的对象

template: "<div class="dd_snippet" id="snippet_84909"><div class="row"> <div class="col-xs-12"><h1 class="padding10">Big title</h1></div></div></div><div class="dd_snippet" id="snippet_46417"><div class="row"><div class="col-xs-12"><h2 class="padding10">Middle title</h2></div></div></div><div class="dd_snippet" id="snippet_20274"><div class="row"><div class="col-xs-12"><h3 class="padding10">Small title</h3></div></div></div>"

I send it like this : 我这样发送:

action.addCampaign = function(idLieu, campaign){
        console.log("Campaign : ", campaign);
        return  $http({
            url: $company.backend+'/lieu/'+idLieu+'/campaign', 
            method: 'POST',
            data: $.param(campaign),
            headers: {'Content-Type': 'application/x-www-form-urlencoded'}
        });
    }

When I display what the server received, I notice that the object containing html is null 当我显示服务器收到的内容时,我注意到包含html的对象为null

Can someone tell me why ? 有人可以告诉我为什么吗?

Thanks for your answers ! 感谢您的回答!

You have some quotes issue; 你有一些报价问题; You can either replace the ones around the javascript string with single quotes. 您可以用单引号将javascript字符串周围的内容替换。 Or escape every double-quote inside your string. 或者转义字符串中的每个双引号。

template: '<div class="dd_snippet" id="snippet_84909"><div class="row"> <div class="col-xs-12"><h1 class="padding10">Big title</h1></div></div></div><div class="dd_snippet" id="snippet_46417"><div class="row"><div class="col-xs-12"><h2 class="padding10">Middle title</h2></div></div></div><div class="dd_snippet" id="snippet_20274"><div class="row"><div class="col-xs-12"><h3 class="padding10">Small title</h3></div></div></div>'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM