JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 31st, 2011, 04:26 AM
trysil trysil is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2011
Posts: 2 trysil User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 5 sec
Reputation Power: 0
Javascript/perl etc

Hi!
I'm making myself familiar with some javascript/perl/AJAX programming and am now stuck on some things.

I have index.php that redirects me to a perl script:

Code:
<?php
	if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
		$uri = 'https://';
	} else {
		$uri = 'http://';
	}
	$uri .= $_SERVER['HTTP_HOST'];
	header('Location: '.$uri.'/FatherTime/user.pl?login');
	exit;
?>


this script displays a simple login form and from there I use AJAX to call the perl script that returns either "unknown" or a user name is the login fails/succeeds.

Code:
function checkUser() {
	var httpRequest = new XMLHttpRequest();
	
	var user = document.getElementById("user").value;
	var pwd = document.getElementById("pwd").value;
	var url = "http://localhost/FatherTime/user.pl" + "?user=" + user + "&pwd=" + pwd;
	httpRequest.onreadystatechange = function () {
		if (httpRequest.readyState == 4 && httpRequest.status==200)
		{
			loadUserPage(httpRequest.responseText);
		}
		if (httpRequest.readyState == 4 && httpRequest.status>=400)
		{
			displayError("Somethings wrong: " + httpRequest.statusText);
		}
	}
	httpRequest.open("POST",url,false);
	httpRequest.send(null);
}


Now what I do in the loadUserPage script I show an alert if the call to user.pl returned "unknown". If the perl script returned a user name I want to load "http://localhost/fathertime/user.pl?<username>".
How? Tried a couple of ways but location.href and location.replace() don't work.

And for some reason no matter what I do in the loadUserPage function the page "http://localhost/fathetime/user.pl" is loaded (no POST or GET variables set).

I'm a bit of newbie when it comes to combining AJAX, javascript, perl... so it's probably something obvious.

ps. I'm running XAMPP with Apache, standard configuration.

/T

Reply With Quote
  #2  
Old October 31st, 2011, 08:01 AM
trysil trysil is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2011
Posts: 2 trysil User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 5 sec
Reputation Power: 0
Found the solution!
I had to use a different metod to access POST data in my perl scripts (using the CGI package)

/T

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Javascript/perl etc


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap