ajax, 提交basic Authorization
2014-03-08 10:10
489 查看
var
url="http://192.168.1.154:8080/test/userAction!sysLogin.action";
//var auth = make_basic_auth('111','111');
alert(make_basic_auth('111','111'));
xmlhttp=null;
if (window.XMLHttpRequest)
{// code for all new browsers
xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{// code for IE5 and IE6
xmlhttp=new
ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlhttp!=null)
{
xmlhttp.onreadystatechange=state_Change;
xmlhttp.open("POST",url,true);
xmlhttp.setRequestHeader("Authorization","Basic
MTExOjExMQ==");
xmlhttp.setRequestHeader("Content-Type",
"text/plain;charset=UTF-8");
xmlhttp.send(null);
}
else
{
alert("Your browser does not support
XMLHTTP.");
}
}
function state_Change()
{
if (xmlhttp.readyState==4)
{// 4 = "loaded"
if (xmlhttp.status==200)
{
// return xmlhttp.status==200;
alert(xmlhttp.responseText);
}
else
{
alert("Problem retrieving XML data");
}
}
url="http://192.168.1.154:8080/test/userAction!sysLogin.action";
//var auth = make_basic_auth('111','111');
alert(make_basic_auth('111','111'));
xmlhttp=null;
if (window.XMLHttpRequest)
{// code for all new browsers
xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{// code for IE5 and IE6
xmlhttp=new
ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlhttp!=null)
{
xmlhttp.onreadystatechange=state_Change;
xmlhttp.open("POST",url,true);
xmlhttp.setRequestHeader("Authorization","Basic
MTExOjExMQ==");
xmlhttp.setRequestHeader("Content-Type",
"text/plain;charset=UTF-8");
xmlhttp.send(null);
}
else
{
alert("Your browser does not support
XMLHTTP.");
}
}
function state_Change()
{
if (xmlhttp.readyState==4)
{// 4 = "loaded"
if (xmlhttp.status==200)
{
// return xmlhttp.status==200;
alert(xmlhttp.responseText);
}
else
{
alert("Problem retrieving XML data");
}
}
相关文章推荐
- jQuery AJAX实现调用页面后台…
- Ajax的几个状态 2010年5月18日
- Java EE。ajax 验证用户名
- ASP.NET Ajax Drag and Drop Table Columns Extender Control/拖拽表列
- ASP.NET AJAX 1.0 源码发布
- Nginx auth_basic+phpMyAdmin…
- ASP.NET AJAX UpdatePanl和FileUp…
- 提交iPhone app程序遇到newss…
- ASP.NET AJAX Drag And Drop
- ASP.NET AJAX 1.0 Beta2 Released!
- ASP.NET Ajax Drag and Drop Table Columns Extender Control/拖拽表列
- ASP.NET AJAX 1.0 Upgrade problems/升级问题
- 页面编码为GBK时 jquery 提交ajax数据完美解决"中文乱码"方案
- HANA Basic SQL 01
- jsp 重复提交解决方法
- ASP.NET AJAX Drag And Drop
- Drupal7-An AJAX HTTP&n…
- 类似公司框架 Ajax与se…
- Jquery 发送ajax请求,action xml…
- HANA Basic SQL 02