Ajax sites with real URL using history.pushState()

If your building a ajax based site then one of the problems you bound to come up on is how to handle pages. There common way to do this, the hastag (#), placing all the information you need to load the desired page after the tag and using the javascript window.location.hash to get it and process the request. This works great, I’ve used it myself before, but it does post 2 problems. Continue reading “Ajax sites with real URL using history.pushState()”

Get GET variables with javascript.

Usually if your working with froms your working with a server side language to take care of the really work involved (I prefer PHP for it) but what if you don’t wat to do it that way, or even can’t? Earlier this weel I was working on a little project that may eventually become an iOS game via PhoneGap and on it there is a form. I wanted this form to both go to another page, but gather and use the information input on that other page. I could have used ajax to reload the document in place but I didn’t really see the advantage of that, the usual speed increase it negligible when your loading all the files locally anyways. Neither Javascript or jQuery have methods in place for reading these get variables, but they do have the ability to rea the URL so with some creative breaking we can get them anyways. Continue reading “Get GET variables with javascript.”

Auto replace broken images.

While most of the time you can check the images your using, either you uploaded them manually or your script will see and, if missing, replacing it with a placeholder image. Sometimes however thats not particularly practical, like when your working mostly in javascript and don’t want to make an ajax call just to see if there an image. Thats the situation I ran into yesterday, and the solution is… Continue reading “Auto replace broken images.”