Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #21719 > unrolled thread
| Started by | Kale <kalezwe@gmail.com> |
|---|---|
| First post | 2013-10-24 20:05 -0700 |
| Last post | 2013-10-27 17:47 +0000 |
| Articles | 8 — 4 participants |
Back to article view | Back to comp.lang.javascript
JS, PHP, and AJAX Kale <kalezwe@gmail.com> - 2013-10-24 20:05 -0700
Re: JS, PHP, and AJAX Gregor Kofler <usenet@gregorkofler.com> - 2013-10-25 09:40 +0200
Re: JS, PHP, and AJAX Denis McMahon <denismfmcmahon@gmail.com> - 2013-10-25 14:44 +0000
Re: JS, PHP, and AJAX Kale <kalezwe@gmail.com> - 2013-10-25 16:29 -0700
Re: JS, PHP, and AJAX Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-10-26 02:04 +0200
Re: JS, PHP, and AJAX Kale <kalezwe@gmail.com> - 2013-10-25 20:30 -0700
Re: JS, PHP, and AJAX Gregor Kofler <usenet@gregorkofler.com> - 2013-10-26 10:40 +0200
Re: JS, PHP, and AJAX Denis McMahon <denismfmcmahon@gmail.com> - 2013-10-27 17:47 +0000
| From | Kale <kalezwe@gmail.com> |
|---|---|
| Date | 2013-10-24 20:05 -0700 |
| Subject | JS, PHP, and AJAX |
| Message-ID | <6ae3bb3b-0d74-4c8f-969b-0e5a9e9a3e05@googlegroups.com> |
So I am trying to make a fake amazon item checker and when I upload the code to my server I get a 500 internal server error. I have a feeling the error is in my JS but it could be in my PHP here is the code.
<DOCTYPE html>
<html>
<head>
<script>
var XH= createXmlHttpRequestObject();
function createXmlHttpRequestObject(){
var XH;
if(window.ActiveXObject){
try{
XH= new ActiveXObject("Microsoft.XMLHTTP");
}
}catch(e){
XH = false;
}else{
try{
XH= new XmlHttpRequest();
}
}catch(e){
XH = false;
}
if(!XH){}
alert('Object not created, Please update your browser and reload the page');
}else{
return XH;
}
}
function first(){
if(XH.readyState==0 || XH.readyState==4){
food = encodeURIComponent(document.getElementById('UI').value);
XH.open("GET", "first.php?food="+food, true);
XH.onreadystatechange = handleServerResponse;
XH.send(null);
}else{
setTimeout('first()',1000);
}
}
function handleServerResponse(){
if(XH.readyState==4){
if(XH.status==200){
XR = XH.responseXML;
XD = XR.documentElement;
M = XD.firstChile.data;
document.getElementById("CI").innerHTML = M;
setTimeout('first()',1000);
}
}else{
alert('We have encountered an issue, please reload the page and update your browser');
}
}
</script>
<style type="text/css">
</style>
</head>
<body onload="first()">
<h1>Amazon.com</h1>
<form>
<input type="text" id="UI">Enter item</input>
<div id="CI">Availability Here</div>
</form>
<?php
header('Content-Type: text/xml');
echo'<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>';
echo'<response>'
$food = $_GET['food'];
$foodArray = array('tomato','kale','macaroni','pineapple');
if(in_array($food, $foodArray))
echo'We have '.$food'!';
elseif($food=='')
echo'please enter a food';
else
echo'sorry we do not sell'.$food'!';
echo'</response>'
?>
</body>
</html>
[toc] | [next] | [standalone]
| From | Gregor Kofler <usenet@gregorkofler.com> |
|---|---|
| Date | 2013-10-25 09:40 +0200 |
| Message-ID | <l4d7a2$9i4$1@dont-email.me> |
| In reply to | #21719 |
Am 25.10.2013 05:05, Kale meinte:
> So I am trying to make a fake amazon item checker and when I upload the code to my server I get a 500 internal server error. I have a feeling the error is in my JS but it could be in my PHP here is the code.
Most likely a *server* error will not be caused by a client side script.
[badly formatted, whitespaced and indented code snipped]
> </form>
> <?php
> header('Content-Type: text/xml');
You are outputting markup and sending a header afterwards? Weird.
> echo'We have '.$food'!';
This doesn't parse. You are missing a concatenation operator.
> elseif($food=='')
> echo'please enter a food';
> else
> echo'sorry we do not sell'.$food'!';
Here again.
Gregor
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2013-10-25 14:44 +0000 |
| Message-ID | <l4e04u$99a$1@dont-email.me> |
| In reply to | #21719 |
On Thu, 24 Oct 2013 20:05:24 -0700, Kale wrote: > So I am trying to make a fake amazon item checker and when I upload the > code to my server I get a 500 internal server error. I have a feeling > the error is in my JS but it could be in my PHP here is the code. What does the php error log on the server say? First you have to work out where it is - possibly /var/log/apache2/errors.log if you have a lamp install. It's quite likely there'll be a message in there telling you (in cryptic php speak) what php error was detected, and giving you a line number and a file name that the error was detected on. Note that the error may be something different to that indicated, and may be in the lines before the indicated line, especially if the error is caused by a simple syntax error like unmatched quotes / braces / parentheses or a missing line terminator. -- Denis McMahon, denismfmcmahon@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | Kale <kalezwe@gmail.com> |
|---|---|
| Date | 2013-10-25 16:29 -0700 |
| Message-ID | <1e30958a-b37f-4856-af91-1dd8fad9f926@googlegroups.com> |
| In reply to | #21726 |
it says error on $food = $_GET['food']; it says PHP Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' How do I fix this line
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2013-10-26 02:04 +0200 |
| Message-ID | <2434662.eOepierZYn@PointedEars.de> |
| In reply to | #21736 |
Kale wrote: > it says error on $food = $_GET['food']; it says PHP Parse error: syntax > error, unexpected T_VARIABLE, expecting ',' or ';' How do I fix this line The line $food = $_GET['food']; is syntactically *valid* *PHP* code. This is a newsgroup on *J(ava)Script/ECMAScript* at its applications. <http://www.catb.org/~esr/faqs/smart-questions.html> -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | Kale <kalezwe@gmail.com> |
|---|---|
| Date | 2013-10-25 20:30 -0700 |
| Message-ID | <bf95a87d-f731-4ee1-9a90-aaa1879af138@googlegroups.com> |
| In reply to | #21737 |
so how do I fix it?
[toc] | [prev] | [next] | [standalone]
| From | Gregor Kofler <usenet@gregorkofler.com> |
|---|---|
| Date | 2013-10-26 10:40 +0200 |
| Message-ID | <l4fv51$eia$1@dont-email.me> |
| In reply to | #21738 |
Am 26.10.2013 05:30, Kale meinte: > so how do I fix it? > By stopping to ignore advices? Search the error in the line *before* the reported one. And then resort to the newsgroup which deals with PHP: comp.lang.*PHP* You can do that, can you? Gregor
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2013-10-27 17:47 +0000 |
| Message-ID | <l4jjk7$16b$1@dont-email.me> |
| In reply to | #21736 |
On Fri, 25 Oct 2013 16:29:50 -0700, Kale wrote: > it says error on $food = $_GET['food']; it says PHP Parse error: syntax > error, unexpected T_VARIABLE, expecting ',' or ';' How do I fix this > line See this part of my earlier post: Note that the error may be something different to that indicated, and may be in the lines before the indicated line, especially if the error is caused by a simple syntax error like unmatched quotes / braces / parentheses or a missing line terminator. -- Denis McMahon, denismfmcmahon@gmail.com
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web