iT邦幫忙

0

請問一下AngularJs

我想問一下,
最近因某些需求要用Angular結合ASP.NET MVC,
目前卡在一個地方,

如果表單中的某個欄位使用到Html標籤,
就會無法傳送資料到後端,

Content-Type換成其他的,
可以傳送但資料是空的,

如果沒有用到Html標籤,
傳送資料一切正常,

但現在就是有需求使用Html標籤,
可以在前端直接Show一些東西,
不知道有沒有大大知道如何解決呢?

Angular的程式碼如下:

//要通過post傳遞的參數 
            var data = { model: itemData},
            //post請求的地址 
            url = "/Admin/EditProductDetail",
            //將參數傳遞的方式改成form 
            postCfg = {
                headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
                transformRequest: function (data) { return $.param(data); }
            };

            $http.post(url, data, postCfg).
                then(function (response, status, headers, config) {
                    if (response["data"] == "true")
                        $scope.showSimpleToast("儲存資料成功!");
                    else
                        $scope.showSimpleToast("儲存資料失敗...");
                },
                function (response, status, headers, config) {
                    $scope.showSimpleToast("傳送資料失敗...");
                });

麻煩各位大大了,
感恩~
/images/emoticon/emoticon41.gif/images/emoticon/emoticon41.gif/images/emoticon/emoticon41.gif

看更多先前的討論...收起先前的討論...
可以編輯一下~讓我看看有加標籤和沒加的差別嗎?0.0
(前陣子有接觸Angular 只是還沒有很熟悉 想了解一下您表達的東西)
froce iT邦大師 1 級 ‧ 2017-09-12 11:45:30 檢舉
你是要送出含 html tag 的 POST 給後端?
小魚 iT邦大師 1 級 ‧ 2017-09-12 11:53:57 檢舉
是的 類似 <iframe> ... <iframe> 之類的,
但是傳送的過程被拒絕,
進不了後端的程式中.
froce iT邦大師 1 級 ‧ 2017-09-12 12:15:50 檢舉
Content-Type改text/xml 呢?
fillano iT邦超人 1 級 ‧ 2017-09-12 13:52:47 檢舉
是這個問題嗎?
https://stackoverflow.com/questions/4759681/post-html-tag-codes-as-string-with-asp-net-mvc-jquery
小魚 iT邦大師 1 級 ‧ 2017-09-12 21:57:55 檢舉
如 fillano 大大說的,已經解決了,原來是被.Net擋下來了,
只要加個 [ValidateInput(false)] 就可以了。
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答