gmoore Posted January 17, 2013 Share Posted January 17, 2013 Which Ajax demo (having not looked at anything Ajax in here) would you recommend for me to use as a basis for toggle buttons to change options on a template header? Example: Red Button/Blue Button/Green Button for default theme to save into a player preference field. Thank you, Greg Quote Link to comment Share on other sites More sharing options...
Someone Posted January 17, 2013 Share Posted January 17, 2013 I think ajax_click_demo would be the sample to look at Think you need to get creative to use the out of the box solution alone for this. But you can print out a jQuery snippet directly to the page, or make your own .js file Quote Link to comment Share on other sites More sharing options...
gmoore Posted January 17, 2013 Author Share Posted January 17, 2013 Thank you sir! Quote Link to comment Share on other sites More sharing options...
Someone Posted January 17, 2013 Share Posted January 17, 2013 no no no, thank you good, sir! Quote Link to comment Share on other sites More sharing options...
gmoore Posted January 17, 2013 Author Share Posted January 17, 2013 My mind is buzzing with possibilities after looking at those demos. Questions, are the Ajax calls protected by the tokens also? I saw nothing in the url that would suggest they were protected as a normal page url would be. Comments? Greg Quote Link to comment Share on other sites More sharing options...
Someone Posted January 18, 2013 Share Posted January 18, 2013 No it does not use the token. $_POST["AJAX"]) && $_POST["AJAX"] == "CALLBACK" are sent with the ajax call to the index.php (line 357) if they are there, it will not include the usual stuff, but rather attempt run the registered function. See libs/ajax.php I am still exploring the ajax functions, bet Alain can provide more details Quote Link to comment Share on other sites More sharing options...
gmoore Posted January 18, 2013 Author Share Posted January 18, 2013 I don't care for basic things I would use Ajax for like preferences and such. I am just concern, for example, if I used it for map movement or something. But Alain I am sure knows what he was thinking. Probably nicely sitting in the documentation. Greg Quote Link to comment Share on other sites More sharing options...
Someone Posted January 18, 2013 Share Posted January 18, 2013 Like here http://www.nw-engine.com/wiki/index.php/Ajax_development The Ajax stuff is very well thought out in my opinion. You should do a check to see that the user is authorized to change the setting though, as you would normally on a page. Quote Link to comment Share on other sites More sharing options...
gmoore Posted January 18, 2013 Author Share Posted January 18, 2013 I just hadn't looked at it until 2 hours ago. Soooooo. Was just wondering. I've used Ajax in .NET and jQuery. But these seems just as easy. So for a button to change a setting. No problem since I will only let you change your own setting. Just wondering if SOMEDAY I do a little game in it. Like Space Invaders. I would just keep state at the server level, so any Ajax coming in would be evaluated against that server state. Actually I should just stop this dreaming, too much core work to do lol Greg Quote Link to comment Share on other sites More sharing options...
Someone Posted January 18, 2013 Share Posted January 18, 2013 (edited) You made me look up ajax space invaders, found this https://github.com/mattiasbrand/SpaceInvaders (no ajax in it) its based on using canvas element, simple little game. Now I am drifting of, back to work.... Edited January 18, 2013 by Someone Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted January 18, 2013 Share Posted January 18, 2013 In NWE post form values are not covered by the token. Why? Because the game must have some ways to give back the values to the server, and how could you pre-calculate the CRC of it before getting it? The only solution would be to have a JS doing some sort of token, but we all know that JS is distributed to the browser as source code, and therefore you would just need to check what's going on to be able to reproduce the CRC of any value. Therefore, the old sentence saying "never trust any user value" is still valid, simply the engine pre-check the GET value and let you fully check the POST one. For a basic example, ajax_click_demo should do the trick I believe. And yes, I tried to make all this ajax / PHP integration as simple as possible. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.