第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

.net mvc Ajax Post 錯(cuò)誤 403 Forbidden

.net mvc Ajax Post 錯(cuò)誤 403 Forbidden

C#
元芳怎么了 2021-07-02 10:07:49
我正在執(zhí)行一個(gè)簡(jiǎn)單的函數(shù)來(lái)更新數(shù)據(jù)庫(kù)中的字段,但出現(xiàn)此錯(cuò)誤:我在 html/Jquery 中執(zhí)行請(qǐng)求:function AgregarLike(id, num){        alert("Entre:" + id);        var urlAction = "@Url.Action("UpdateLikeVisitBrandPhoto", "Report")";        alert (urlAction);        var request;        // Fire off the request to /form.php        request = $.ajax({        url: urlAction + '/' + id,        type: "post"        });       // Callback handler that will be called on success       request.done(function (response, textStatus, jqXHR){       // Log a message to the console       console.log("Hooray, it worked!");       console.log(response);       console.log(textStatus)       alert("worked");       });}和控制器(我一直返回 bu.CreateLike(Id) 因?yàn)槲蚁霃?qiáng)制錯(cuò)誤):   public int UpdateLikeVisitBrandPhoto(int id)    {        try        {            try            {               var num = bu.CreateLike(id);            }            catch            {                return bu.CreateLike(id);            }            return bu.CreateLike(id);        }        catch (ServicesException ex)        {            logger.Error("", ex);            Console.WriteLine(ex);            return bu.CreateLike(id);        }        catch (Exception ex)        {            logger.Error("", ex);            Console.WriteLine(ex);            return bu.CreateLike(id);        }    }和模型: public int CreateLike(int id)    {        using (var sqlConnection = DatabaseUtilities.GetConnection())        {            var SQL = "UPDATE [RBAcuerdos].[dbo].[VisitBrandPhoto] SET MeGusta = 1 WHERE id = @paramId";            var sqlCommand = new SqlCommand(SQL, sqlConnection);            sqlCommand.Parameters.Add(new SqlParameter("paramId", id));            //sqlCommand.Parameters.Add(new SqlParameter("paramvalue", 1));            return sqlCommand.ExecuteNonQuery();        }        //throw new NotImplementedException();    }有人可以幫助我嗎?
查看完整描述

2 回答

?
SMILET

TA貢獻(xiàn)1796條經(jīng)驗(yàn) 獲得超4個(gè)贊

request = $.ajax({

        url: urlAction + '?id=' + id,

        type: "get"

        });

替換您的代碼


var urlAction = "@Url.Action("UpdateLikeVisitBrandPhoto", "Report")";

它產(chǎn)生


/Report/UpdateLikeVisitBrandPhoto

要點(diǎn)擊控制器,你需要你的網(wǎng)址


/Controller/Action?param1=paramvalue //single param

/Controller/Action?param1=paramvalue &param2=paramvalue //multiple params,apppend each paramname with prefix &


查看完整回答
反對(duì) 回復(fù) 2021-07-03
?
守著星空守著你

TA貢獻(xiàn)1799條經(jīng)驗(yàn) 獲得超8個(gè)贊

由于您正在發(fā)送 POST 請(qǐng)求,因此您需要發(fā)送的參數(shù)不應(yīng)是 URL 的一部分。嘗試發(fā)送如下參數(shù):


 request = $.ajax({

    url: urlAction,

    data: {id: id},

    type: "POST",

    contentType: 'application/json; charset=utf-8',

    success: function (data) {

       alert("It worked!");

    },

    error: function () {

       alert("Error");

    }

 });


查看完整回答
反對(duì) 回復(fù) 2021-07-03
  • 2 回答
  • 0 關(guān)注
  • 288 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)