AJAX POST problem using F2 Preview and a subst drive

Post your questions and problem reports here

Moderator: kfury77

Forum rules
Please try to follow these guidelines. This will help to receive faster and more accurate response.

  • Check the Support section of the corresponding product first. Chances are you will find your answer there;
  • Do not create new topics for already reported problems. Add your comments to the existing topics instead;
  • Create separate topic for each problem request. Do NOT post a number of non-related problem reports in a single topic;
  • Give your topic a meaningful title. Titles such as "A question," "Bug report" and "Help!" provide others no clue what your message is about;
  • Include the version number of the software you are using;
  • This is not an official customer support helpdesk. If you need a prompt and official response, please contact our support team directly instead. It may take a while until you receive a reply in the forum;

AJAX POST problem using F2 Preview and a subst drive

Postby dcromley » Sat Mar 07, 2015 12:44 am

I'm a happy Rapid PHP 2015 (V 13.2.0.164) user for just 3 months. This looks like a problem that has narrow scope, but I hope it is easily fixed. The work-around is obvious.

I have reduced my problem to the following 2 scripts. php1.php has 2 buttons -- the first makes an ajax GET request to php2.php expecting "(GETq=abcGETdef)" and the second makes an ajax POST request to php2.php expecting "(POSTq=abcPOSTdef)".

Using the URL http://localhost/php1.php:
I get the expected results: "(GETq=abcGETdef)" or "(POSTq=abcPOSTdef)"

Using the F2 preview gives the URL http://localhost:89/~X/php1.php:
I get "(GETq=abcGETdef)" (correct) for the GET button, but
I get "(POSTq=abcP)(GETq=abcPOSTdef)" (wrong) for the POST button.

This only happens when I edit my scripts using the X: drive.
1) my webroot is "C:/xampp/htdocs"
2) X: is defined to be "C:/xampp/htdocs" in a boot .bat file
"subst X: C:/xampp/htdocs"
There is no problem when I edit my scripts using the C: drive.

The "subst X: C:/xampp/htdocs" works fine for all other uses.
Thanks for your product.

php1.php:
Code: Select all
<script type="text/javascript">
function doajaxget() {
  var oReq = new XMLHttpRequest();
  oReq.onload = function() { alert(oReq.responseText); }
  oReq.open("get", "php2.php?q=abcGETdef", true);
  oReq.send();
  }
function doajaxpost() {
  var oReq = new XMLHttpRequest();
  oReq.onload = function() { alert(oReq.responseText); }
  oReq.open("post", "php2.php", true);
  oReq.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  oReq.send("q=abcPOSTdef");
  }
</script>
<body>
<button type="button" onclick="doajaxget();">ajaxGET</button>
<button type="button" onclick="doajaxpost();">ajaxPOST</button>
</body>
</html>


php2.php:
Code: Select all
<?php
  $ret = "";
  if (isset($_POST['q'])) $ret .= "(POSTq=" . $_POST['q'] . ")";
  if (isset($_GET['q'])) $ret .= "(GETq=" . $_GET['q'] . ")";
  if ($ret == "") $ret = "none";
  echo $ret;
?>
dcromley
 
Posts: 1
Joined: Thu Jan 22, 2015 6:24 am

Re: AJAX POST problem using F2 Preview and a subst drive

Postby Aivars » Mon Mar 09, 2015 10:29 am

Open menu Options -> Preferences -> Preview -> Mappings and add a new mapping that defines (C:/xampp/htdocs => http://localhost/) then preview will use your XAMPP instance instead of the built in server for this location.
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2453
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia


Return to HTMLPad / Rapid CSS / Rapid PHP / WeBuilder Support

Who is online

Users browsing this forum: No registered users and 9 guests

cron