• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Nymall

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

2 posts in this topic

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 http://127.0.0.1/New%20Pointless/%7B 404 (Not Found) jquery-1.9.1.js:2358
GET http://127.0.0.1/New%20Pointless/%22 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(){
    loadbyref('S00010000');
    $('#text').hide();
    $('#textfill').hide();
}
function loadbyref(LocByRef) {
    $.post('game.php',                  //the script to call to get data          
      {
        atr:LocByRef
      },
      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);
        if(convo!=true){
            $('#text').hide();
            $('#textfill').hide();
            if(people!="nil"){
                $('#people').show();
                $('#people').attr("src", people);
                $('#people').attr("onClick", personlink);
            }else{
                $('#people').hide();
            }
        }else{
            $('#people').show();
            $('#people').attr("src", people);
            $('#text').show();
            $('#textfill').show();
            $('#textplace').html(convotext);
            if(buttonone!='nil'){
                buttonoutput = buttonone;
            }
            if(buttontwo!='nil'){
                buttonoutput += buttontwo;
            }
            if(buttonthree!='nil'){
                buttonoutput += buttonthree;
            }
            $('#buttonfill').html(buttonoutput);
        }
      } 
    );
}
 

 

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

 

{"0":"mydorm.png","1":false,"2":"nil","3":"nil","8":"nil","4":"nil","5":"nil","6":"nil","7":true}

 

 

 
Is there something obvious I'm missing? Any help would be appreciated!
Edited by Nymall
1

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0