Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ajax POST requests credentials, GET does not

Status
Not open for further replies.

ESquared

Programmer
Dec 23, 2003
6,129
US
I am using integrated authentication for a company intranet web site I'm building. All clients will be IE 6 or 7.

I've successfully built some ajax functionality using GET but now want to leverage existing pages that expect a POST. So I found code that does in fact work. But the wrinkle I get is that when I initiate the ajax request I am prompted for my credentials.

The site I am POSTing to is the same as the page I am on and the same as when I do GETs through ajax.

Is there something I can do to not be asked for my domain credentials? I searched the web and this forum for a while but was unsuccessful. The terms "integrated authentication" and "credentials" are not to be found in this forum, but are so common on the web that I can't zero in on any specific ajax authentication content.

Here's my code if you want to see it:

Code:
function testReceive(xmlhttp) {
   if (xmlhttp.readyState!==4) {return;}
   $("popup2content2").innerHTML = xmlhttp.responseText;
   xmlhttp = null;
}

function httpPost(url, params, stateChangeFunc) {
   var xmlhttp = ajaxObj();
   if(xmlhttp) {
      xmlhttp.onreadystatechange = function(){stateChangeFunc(xmlhttp);};
      xmlhttp.open("POST", url, true);
      xmlhttp.setRequestHeader("Content-type", "application/x-[URL unfurl="true"]www-form-urlencoded");[/URL]
      xmlhttp.setRequestHeader("Content-length", params.length);
      xmlhttp.setRequestHeader("Connection", "close");
      xmlhttp.send(params);
   }
}

function popup2Action() {
   var params = 'formpassthrough=' + escape(encodeURI('dataaction.asp')) + '&blah=' + escape(encodeURI('gorp'));
   httpPost('[URL unfurl="true"]http://myserver/info.asp',[/URL] params, testReceive);
}
I actually will be processing the response text myself instead of sticking it in my popup's innerHTML, but for test purposes this is just fine.
 
Never mind. The problem went away by itself. It probably was a weird browser state and opening a new browser window probably fixed it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top