473,383 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Passing a URL works sometimes, but not often

I have an interesting (horribly frustrating) problem here. My goal is to write a Euchre game in JavaScript. I am using a PHP script to update game information and retrieve the current game status. The following code is a snippet of JavaScript, where http is an XMLHttpRequest object.

Expand|Select|Wrap|Line Numbers
  1. http.open("GET", "euchre_play.php" + location.search + "&card=" + card, false);
  2. http.send(null);
The location.search property contains the string "?table=XX&player=XX". This is passed in to the JavaScript game client as the query portion of the url. By simply passing this string along to the PHP script, I avoid having to parse it in the JavaScript. I have another bit of code in my JavaScript which is nearly exactly the same... it just uses a different PHP script, and that part works fine.

The problem is, the above code does not always work. I have actually gotten it to work on occasion, exactly as written. I usually accomplish this by using a single string, fully formed URL. I can then strip off parts of that URL one by one and replace other parts with variables, such as 'location.search' and 'card'. However, what usually happens is that the first time I run the script as written above, it works! Subsequently, it fails to work every time!
Jun 6 '06 #1
3 1602
Also, I should mention that I have tried using an IFrame instead of an XMLHttpRequest object, with the exact same outcome... sometimes it works, but the vast majority of the time it does not.

I have also used an alert box to notify me of what my url string looks like, and it looks perfectly reasonable. For instance, something like "euchre_play.php?table=1&player=4&card=2"
Jun 6 '06 #2
After looking at every bit of code for hours on end, I finally found an error in my php script. Thanks if you actually looked at this, but I hope you didn't waste your time.
Jun 6 '06 #3
ablaye
11
Good for you :D
Jun 7 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
12
by: Patrick | last post by:
I have two ASP pages payment.asp: For customers to fill in payment/card details (pre-populating details if details submitted were invalid and user had to re-fill in details) confirmorder.asp:...
6
by: Garma | last post by:
According to what I have learnt so far, instantiating global objects should be the last resort. Is there any reasons why so? Sometimes some objects or their pointers have to be shared among...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
9
by: justanotherguy63 | last post by:
Hi, I am designing an application where to preserve the hierachy and for code substitability, I need to pass an array of derived class object in place of an array of base class object. Since I...
5
by: lawrence | last post by:
Here is a script that is suppose to turn the DIV tag "optionalDiv" visible on click. This works fine on a PC (IE and Netscape both I think) but not on a Mac. Why? <script...
10
by: WindAndWaves | last post by:
Hi Folks I know that this is possible: Function tt(x as string, nv()) where NV is an array. What I am wondering is if NV can be a multidimensional array.
11
by: truckaxle | last post by:
I am trying to pass a slice from a larger 2-dimensional array to a function that will work on a smaller region of the array space. The code below is a distillation of what I am trying to...
12
by: Mike | last post by:
Consider the following code: """ struct person { char *name; int age; }; typedef struct person* StructType;
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.