angular / angular.js

AngularJS - HTML enhanced for web apps!
https://angularjs.org
MIT License
58.79k stars 27.48k forks source link

Fail with sending HTML via $http #1654

Closed MathRobin closed 11 years ago

MathRobin commented 11 years ago

I've a specific situation which give me a problem. That's my simplified code :

myObjectContainingHTML = {
    something : "a",
    html : "<table align=\"center\"><tr><td>foo</td><td>bar</td></tr></table>"
};

myParams = {
    otherthing : 'b'
};

kapsule = {
                provider : 'wizard',
                data     : 'kapsule=' + JSON.stringify({
                    data           : myObjectContainingHTML
                }),
                params         : myParams,
                cache    : false
            };

proxy(kapsule);

But that's give that request "Form Data" in Dev Tools :

kapsule:{"something":"a"; "html_content":"<table align
amp;utm_source:n
nbsp;!  </span></td> </tr> </tbody></table>  <table align:\"center\" border

It breaks the stringgived to data. But if I remove JSON.stringify it doesn't work too and I've tried with .toString() instead of, but no more interesting results.

How do you provide HTML string to $http ?

pkozlowski-opensource commented 11 years ago

@MathRobin what do you mean exactly by "But if I remove JSON.stringify it doesn't work"? I've just created a jsFillde where I can POST an object with HTML tags inside: http://jsfiddle.net/kWVVs/2/

Anyway, it sounds more like a general question about AngularJS usage and not a bug report / feature request. As such would be better asked on the mailing list (https://groups.google.com/group/angular) or the IRC (#angularjs) channel. The mailing list is very active and people there will be happy to help.

Going to close this one for now, please reopen if you believe that there is a bug in AngularJS.