Win a copy of Learn Spring Security (video course) this week in the Spring forum!
    Bookmark Topic Watch Topic
  • New Topic

Help with JSON

 
Duran Harris
Ranch Hand
Posts: 608
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi all,

I'm busy building a minesweeper game in PHP and javascript.
Only problem is that I need to pass php the value of a javascript variable.
So...I downloaded the json.js file.But unfortunately,I dont know how to use it.
Assuming that I have:



Please help,I don't wanna go back to the scripted version of minesweeper!!

 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Report post to moderator
That prompt happens after you serverside code has run so you are not able to use that there.

The serverside code runs on the server. The clientside code runs on the client after the serveride code is fully done running and it is sent to the client.

Only way you can get your serverside code to interact with clientside code like that is through Ajax calls.

Eric
 
Duran Harris
Ranch Hand
Posts: 608
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
Okay so I've tried to implement AJAX for the 1st time...everything seems to be working fine,I can even verify that the correct parameters are being sent in each AJAX
request.Only problem is that my php code that accesses the parameters(sent with XMLhttpRequest.open(,'GET',localhost\queryString,true) isn't executing at all..No echoes no nothing.
Please help:




It's the phpCatch() method called by doAJAX() that's not executing..
 
Duran Harris
Ranch Hand
Posts: 608
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
To explain how it works:

A user clicks on a cell in the table...the cells id is passed to the doAJAX() method which sends it via get to the phpCatch() method.
phpCatch() is then supposed to run a switch on the parameters to continue the game logic.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please do not double post here...http://www.coderanch.com/t/427259/HTML-JavaScript/AJAX-method

CLosing this one, discussion can continue there.
 
    Bookmark Topic Watch Topic
  • New Topic