Forum Moderators: open

Message Too Old, No Replies

Looking for a good place to start

Beginning Javascript

         

fransko

2:20 am on Dec 19, 2006 (gmt 0)

10+ Year Member



I am familiar with procedural php and mysql programming, but i have been having some problems with a script that i have been working on for the last few days.
This is all still pretty new to me but is i am looking for a good and brief overview of how to merge php mysql and javascript, is that what AJAX is all about? What is the big idea behind it?
i feel like i might be approaching the whole thing wrong.

cmarshall

2:36 am on Dec 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oooh... Don't start with AJAX. You'll go bonkers.

AJAX is an asynchronous technology, which is a bit mind-bending. There are lots of big ugly hairy things with sharp, pointy teeth. The notion of "predictable context" tends to go swirling down the toilet in async, and you have to do wierd things to get your feet back under you.

However, if you do decide to jump in the deep end without your water wings, you will find, that yes, it does involve merging all these techs, but you'll get the same effect from looking at the code for pretty much any modern CMS like WordPress [wordpress.org]. They will often involve a wee bit of AJAX, but are mostly good old-fashioned code.

eelixduppy

2:42 am on Dec 19, 2006 (gmt 0)



Welcome to WebmasterWorld [webmasterworld.com], fransko!

Here's a place to start [w3schools.com].

You may also get some other useful information by doing a simple Google Search [google.com] or a WebmasterWorld Search [google.com]

Good luck! :)

physics

3:14 am on Dec 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello fransko, welcome to WebmasterWorld.com!

Yes that's what AJAX is all about. And it doesn't have to be as painful as some think ;) but it is a different way of programming your sites and in that way it is a bit painful getting started.

Since you like PHP here is the mostly painless intro to AJAX by the creator of PHP:
Rasmus Lerdorf 30 Second AJAX Tutorial [news.php.net]

If you want a more seamless/cross-browser way to do AJAX with more functions look into a package like Dojo, Prototype or Script.aculo.us. Those will also allow you to incorporate animations and in some cases widgets, etc. See, for example:
Dojo Hello World Tutorial [dojo.jot.com]

I also recommend the book Pragmatic AJAX.

fransko

5:34 am on Dec 19, 2006 (gmt 0)

10+ Year Member



Thank you guys for all of those great links and tips for getting started. However, in order to understand and use it wouldn't i need to take a few more steps backwards and learn XML and Javascript really well? (i already know CSS and HTML well enough).
Maybe it is just a retorical question with no answer, but it seems like i am constantly having to backtrack to build a better foundational knowledge before i continue to learn the 'new stuff'. Does anyone else face that?

cmarshall

9:53 am on Dec 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Funny you should mention that.

I just came upon a pretty good site with all sorts of stuff that you might find fascinating.

[javascriptkit.com...]

[edited by: encyclo at 3:38 am (utc) on Dec. 20, 2006]

physics

5:22 am on Dec 20, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



fransko, whether you go back and learn JavaScript really well is a matter of preference. You already know how to program PHP so the basic language constructs of JavaScript should not me much of an issue. Personally, sometimes I like to jump in and grab a book to learn what I need to know when I decide I need it ... other times I want to read a whole book first. In the case of learning AJAX I read a whole book about AJAX first (not JavaScript). Feel free to devour a JavaScript book first but the best one (JavaScript: The Definitive Guide) is > 900 pages long so get some coffee first. From what I've seen you can write effective AJAX applications without really knowing much about JavaScript, since the main thing you'll want to do is just exploit the asynchronous http requests. You can even accomplish feats that make you look like a JavaScript master just by leveraging a library like Dojo as I mentioned before.
Also, note that you don't have to know anything about XML to write AJAX applications. You can use JSON or even comma-separated-value format as the data exchange from PHP to JavaScript (see Rasmus' tutorial). I've been using JSON and like the fact that it requires minimal work from me to encode data on the PHP side and then decode it on the JavaScript side. You actually don't need to know much about JSON except how to call the functions that do then encoding/decoding.

fransko

6:25 am on Dec 20, 2006 (gmt 0)

10+ Year Member



Funny that you should mention JavaScript: The Definitive Guide, i have an old copy (from 97) that i have been reading at night. But that might not last very long after my new AJAX book arrives in the mail.
Thank you very much for being so helpful- i will definitely pursue the options that you mentioned (the JSON website looks a bit intimdating), but i can't wait to see what i can accomplish!

physics

6:55 am on Dec 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That's the spirit ;)
Don't be intimidated by the JSON web site. All you need is something to encode your PHP array/object on the PHP side and then use JavaScript's built in eval() function to decode the array/object. It essentially is a way to pass an array or complex object from your PHP code to your JavaScript. Getting that working for the first time can be a pain though...
But as I said you don't necessarily even need to do that, you might just want to pass information as fully formatted HTML code from your PHP and then plug that into your page using JavaScript's innerHTML.
Good luck.

physics

7:02 am on Dec 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



By the way, you should probably pick up a newer version of the JavaScript book since JS and the way it is implemented in browsers is always changing. The 5th edition just came out in August 2006, ISBN: 0596101996 so it's pretty fresh.