View Full Version : Sending data with xmlhttp

05-12-2009, 04:07 AM
Hey all i am in need of some help with the xmlhttp ajax stuff. I am using a script called "SEXYALERTBOX". I am using it to allow the user to input a password. The textbox is called BoxPromptInput. I do not think its inside a <form> tag.

Here is the code:

function askForPass() {
Sexy.prompt('Please type the password in order to see the pictures/videos','' ,{ onComplete:
function(returnvalue) {

var xmlhttp = false;
var pageResponse = null;

try{xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");}
catch (error){try {xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");} catch (error) {xmlhttp = false;}}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {try {xmlhttp = new XMLHttpRequest();} catch (error) {xmlhttp=false;}}
if (!xmlhttp && window.createRequest) {try {xmlhttp = window.createRequest();} catch (error) {xmlhttp=false;}}

var parameters = "";
var url = "mediacheck.asp";
var formArray = returnvalue;

for(i=0; i < formArray.length; i++) {parameters = parameters + formArray[i].name + "=" + encodeURIComponent(formArray[i].value) + "&";}

xmlhttp.open("POST", url + '?' + Math.random(), true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", parameters.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
else {
alert('An error occurred: ' + xmlhttp.status + ' ' + parameters);


How can i pass the value inside the BoxPromptInput box to my mediacheck.asp page?

This is what my mediacheck.asp page looks like:

Dim myPass

myPass = request.form("BoxPromptInput")

if myPass = "mypasstest" then
Session("mediasee") = "yes"
Session.Timeout = 30
response.write "WORKED!"
Session("mediasee") = "no"
response.write "NOTWORK"
end if

Could anyone help me out finding a way to pass the value since im sure the request.form would not work in this case since its not in a form.

Any help would be great! THANKS! :)


Old Pedant
05-12-2009, 09:47 AM
Yes, it *IS* in a FORM. So far as the ASP code is concerned.

That's what the lines here are doing:

for(i=0; i < formArray.length; i++) {parameters = parameters + formArray[i].name + "=" + encodeURIComponent(formArray[i].value) + "&";}


The parameters are simulating the effect of a <FORM METHOD=POST>.

So *if* your formArray includes that field it should work.

But the formArray is coming from this code:

var formArray = returnvalue;

and the returnValue is coming from the function call argument:

function(returnvalue) {

But I don't pretend to know what the heck is setting the value of that argument, since you don't show your other code.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum