js ajax 401,jquery - 401 Unauthorized on .ajax post - Stack Overflow

I wanted a solution that enabled me to allow the page I was doing the post on to be run through sitecores context. If you don't mind the page ignoring the context look at Mark Ursino answer it will work like a charm.

My answer does the following:

Javascript:

function MySuperCoolFunction() {

strUser1 = document.getElementById("Symbol1").innerHTML;

strUser2 = document.getElementById("Symbol2").innerHTML;

var join = strUser1 + "," + strUser2;

__doPostBack('upCurrencyCharts', join);

}

.ascx/.aspx:

// My Content Here

.cs:

protected void upCurrencyCharts_onload(object sender, EventArgs e)

{

string item1 = null;

string item2 = null;

if (IsPostBack)

{

string items = Request["__EVENTARGUMENT"];

string[] partsArray = items.Split(',');

for (int i = 0; i < partsArray.Length; i++)

{

if (i == 0)

{

item1 = partsArray[i];

}

if (i == 1)

{

item2 = partsArray[i];

}

}

}

// do something with item1 and 2 here.. in mycase feed to database.

The javascript forces a postback event on my update panel, and parses a string of parameters I am sending through to the backend of my website. Onload event triggers on postback and fires anything I do in my onload event in this case puts the items into an array to split them and then puts them into a database. Simples. Thanks everyone for there help in this. :D

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值