FORUM HOME | WHUK BLOG   
WEB HOSTING UK AFFORDABLE WEBSITE HOSTING SERVICES IN UNITED KINGDOM
PHP LINUX SHARED HOSTING WINDOWS ASP.NET HOSTING PACKAGES
ECOMMERCE HOSTING ASP MSSQL MS ACCESS ODBC FRONTPAGE HOSTING
CPANEL WHM FANTASTICO RESELLER DEDICATED SERVER WEB HOSTING
CHEAP PLESK CPANEL HTML MYSQL BEST UK VPS HOSTING COMPANY
CHEAP RELIABLE UK HOSTING PROVIDER SINCE 2001
MANAGED WEB HOSTING SERVICE
AFFORDABLE WEBSITE HOSTING SERVICES IN UNITED KINGDOM

Web Hosting UK Forums | Linux Windows Dedicated Server and cPanel VPS Hosting Forum » Web Hosting and Domains » FAQ's / Tutorials.

Reply
 
LinkBack Thread Tools Display Modes

  #1 (permalink)  
Old 02-06-08, 07:42 AM
new member
 
Join Date: Jul 2006
Posts: 6
Default Javascript XMLHttpRequest POST

Hi,

I've been testing a page on my local machine and part of it passes a very long string (4000+ chars) to a php script. Using GET this fails. However on my local machine POST works. As soon as I upload it to the server it does not work and cannot seem to find the php file. Instead it seems to redirect to the domain root index file.
I do not have an .htaccess file in the directory where I am running this page from and I have commented out all entries in my root .htaccess.

See the code below - in this case I have simplifed it to only be posting a very short parameter but it does the same thing.

Code:
loadXMLDocTEST("saveRouteTEST.php");

function loadXMLDocTEST(url) {
  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) {
  
    var params = "route1=sd";
    
    xmlhttp.onreadystatechange = callBackTEST;
    xmlhttp.open("POST",url,true);
    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlhttp.setRequestHeader("Content-length", params.length);
    xmlhttp.setRequestHeader("Connection", "close");
    xmlhttp.send(params);
    
  }
  else {
    alert("Your browser does not support XMLHTTP.");
  }
}

function callBackTEST() {
  if (xmlhttp.readyState==4) {// 4 = "loaded"
    if (xmlhttp.status==200) {// 200 = OK
      //alert(xmlhttp.responseText);
      alert(xmlhttp.responseText);
      
    }
    else {
      alert("Problem retrieving XML data");
    }
  }
}
I can run a very similar script which uses GET and it works fine and finds my php file with no problems so to me it seems there is an issue with the POST.
Anyone got any ideas? Is POST blocked by the servers?

Thanks,

Mudders

Last edited by mudders; 02-06-08 at 08:11 AM.
Reply With Quote

  #2 (permalink)  
Old 02-06-08, 03:55 PM
Senior Member
 
Join Date: Jan 2007
Location: Dorset
Posts: 1,119
Default

i'm not really up on XMLHttpRequest as i had problems trying to use it successfully with F|lex, but what is being returned from your script? Is the XML well formed?
Reply With Quote

  #3 (permalink)  
Old 03-06-08, 06:38 AM
new member
 
Join Date: Jul 2006
Posts: 6
Default

Quote:
Originally Posted by jon123 View Post
i'm not really up on XMLHttpRequest as i had problems trying to use it successfully with F|lex, but what is being returned from your script? Is the XML well formed?
Hi,

At this stage its not even seeing my script. the php script just prints out "Done...". Thats it.
But the return value I'm getting is the output of the index.html file at the root of the domain.

I've since figured out that this problem seems to be Firefox3 specific. I've been doing all my testing on Firefox3 and then I tried it in IE and Firefox2 and it works in both those browsers so seems to be a browser specific issue.

Mudders
Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT. The time now is 12:41 PM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Copyright 2001-2010 Web Hosting UK. All rights reserved.
Web Hosting UK Forum





Site Map

Shared Cloud
Shared Cloud From £1

Affiliate Program
Earn up to £300 Per Sale

Dedicated Servers
Dedicated Server Hosting

Cloud Hosting
Cloud Server Hosting

Load Balanced Server
Load Balancing Server

VPS Hosting
Linux VPS Hosting

Windows VPS
Windows 2003 VPS

Zimbra Hosting
Zimbra Email Hosting

cPanel Hosting
Shared Linux Hosting

Windows Hosting
Shared Windows Hosting

Coldfusion Hosting
Windows Coldfusion Hosting

cPanel Reseller Hosting
Reseller Hosting

Windows Reseller
Windows Reseller Hosting

Email Web Hosting
Email Hosting

Semi-Dedicated Server
Semi-Dedicated Hosting

Remote Backup Plans
Offsite Backup Service


cpanel hosting
Knowledgebase Articles

Pre-Sales Question
Web Hosting FAQ's

Dedicated Hosting
Dedicated Server FAQ's

Virtual Private Servers
VPS Hosting

PHP MySQL Hosting
cPanel Hosting

Windows Hosting
ASP MSSQL Hosting

Domain Name
Domain registration FAQ's

CMS Hosting
CMS Hosting FAQ's

Payment Gateways
Payment FAQ's


Support Tutorials

cPanel Tutorials
cPanel Flash Tutorials

Wordpress Tutorials
Wordpress Flash Tutorials

Plesk Tutorials
Plesk Flash Tutorials

PhpMyadmin Tutorials
PhpMyadmin Flash Tutorials

Drupal Tutorials
Drupal Flash Tutorials

Mambo Tutorials
Mambo Flash Tutorials

Joomla Tutorials
Joomla Flash Tutorials

More Hosting Tutorials