Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Passing form variables with JavaScript
Old 02-08-2007, 03:38 PM Passing form variables with JavaScript
Average Talker

Posts: 20
Trades: 0
Does anyone know of a way to pass uploaded files from forms using AJAX/JavaScript?

I sense the problem is in the javascript (which is why I'm posting it here). Here's the code:

Code:
// declaring javascript variable (in .js file) for uploaded file with form name 
// 'userfile1'
var postUserfile1 = theForm.userfile1.name + "=" + encodeURIComponent( theForm.userfile1.value );

// calling makeRequest function to pass variable to AJAX request
makeRequest(url, postUserfile1);
And finally, here's the makeRequest function:
Code:
//Initiate the AJAX request
function makeRequest(url, param) {
//If our readystate is either not started or finished, initiate a new request
 if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
   //Set up the connection to captcha_test.html. True sets the request to asyncronous(default) 
   receiveReq.open("POST", url, true);
   //Set the function that will be called when the XmlHttpRequest objects state changes
   receiveReq.onreadystatechange = updatePage; 

   //Add HTTP headers to the request
   receiveReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   receiveReq.setRequestHeader("Content-length", param.length);
   receiveReq.setRequestHeader("Connection", "close");

   //Make the request
   receiveReq.send(param);
 }   
}
thanks all!
sage
__________________
Website:

Please login or register to view this content. Registration is FREE
ffsja is offline
Reply With Quote
View Public Profile Visit ffsja's homepage!
 
 
Register now for full access!
Reply     « Reply to Passing form variables with JavaScript
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.07909 seconds with 12 queries