Jump to content

View more

Image of the Day

WIP title screen for #DeathOfAPartisan #screenshotsaturday #gamedev https://t.co/qJNhfZCvd4
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Sign up now

Javascript/Jquery strange errors, trying to get %22 and %7B?

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Nymall   Members   


Posted 22 February 2013 - 11:25 AM

UPDATE: I've discovered the problem, and now I feel foolish. I accidentally removed the JSON parsing, and for one reason or another tried to re-implement it by accessing it as a array. It's one of those mistakes that is done at 1am on a saturday, and never rediscovered. Thank you for responding, though!
Hey guys,
I've been working on a project for my wife in my free time, a type of adventure game in PHP. She's been doing the writing, and as I've been a dabbling programmer for many years I've taken up the mantle of developer.
The game is written in PHP, and it's using Javascript and Jquery to dynamically get data from the PHP script through JSON and enact changes on the page dynamically. For quite a while, development has been going good and it was almost playable for a short period of time... then, this happened:


GET 404 (Not Found) jquery-1.9.1.js:2358
GET 403 (Forbidden) jquery-1.9.1.js:2358


The data from the php script is JSON, and I've confirmed that it's being sent properly, and I have error suppresion on that side so it's not throwing a monkey wrench in the works... I'm really not sure why this is happening. I've done SEVERAL hours of investigation on these errors, and I haven't the foggiest clue why they exist.
I've gone to the area quoted by the chrome console, and it appears to be in the .attr function of jquery. The thing is, there are no get commands called by the javascript for either %7B or %22. I took a guess that they might be rogue characters, but I can't find anywhere in the javascript where " and { are sent via get.
Here's the javascript code as it stands:
<script language="javascript">
function onstart(){
function loadbyref(LocByRef) {
    $.post('game.php',                  //the script to call to get data          
      function(data)          //on recieve of reply
        var background = data[0];
        var convo = data[1];
        var convotext = data[2];
        var people = data[3];
        var buttonone = data[4];
        var buttontwo = data[5];
        var buttonthree = data[6];
        var islocation = data[7];
        var personlink = data[8];
        var buttonoutput = "";
        $('#gamescreen').attr("src", background);
                $('#people').attr("src", people);
                $('#people').attr("onClick", personlink);
            $('#people').attr("src", people);
                buttonoutput = buttonone;
                buttonoutput += buttontwo;
                buttonoutput += buttonthree;


And here is the example of the response from the php script:





Is there something obvious I'm missing? Any help would be appreciated!

Edited by Nymall, 22 February 2013 - 01:27 PM.

My favorite error yet:

Parse error: Syntax error, unexpected '$pants'...

#2 EmployeeNumber8   Members   


Posted 22 February 2013 - 12:53 PM

Check all of the src attributes that get updated. One of them is most likely the culprit.

In the callback function, it looks as if you set the src property of a few elements. Debug using the chome dev tools again and set a breakpoint somewhere inside that callback. Just examine the src of every element as it gets updated. 


like this one:


$('#people').attr("src", people);

Or just step through the code by pressing F10, and then see which one causes the error.

#3 Havsmonstret   Members   


Posted 22 February 2013 - 02:29 PM

Edit: Didn't read closely enough.

Edited by Navall, 22 February 2013 - 02:30 PM.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.