Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question 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.

    Code:
    http.open("GET", "euchre_play.php" + location.search + "&card=" + card, false);
    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!

  • #2
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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"

  • #3
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Nevermind

    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •