Converting from xajax + jQuery to just jQuery

I’ve been working on the web based version of WSManage for a couple of weeks now, getting the mess I have straightened out.  WSManage is the console that my dad uses to administer the video/audio clips on http://www.winningsideministries.org.  When I originally coded it, I used xajax to communicate with the server side and manipulated the gui with pure javascript.  Then, I found how easy it was to work with the gui if I used jQuery instead of coding all the javascript by hand.  This was nice, besides the fact that I had a lot of places where I’d have a button click handler calling xajax, which wrote jQuery code to manipulate the gui from the server-side.  Not cool.

So, I’ve been going back and replacing all the xajax server code with php that just prints the return data, and using jQuery’s ajax functions to make the calls to the server.  This way I can handle the data on the server, send back anything I need to the javascript, and handle gui manipulation ONLY in the javascript.  The separation of data/model from the view is much nicer and much easier to maintain.  Not only is the code less cluttered, but there are fewer lines of code in general and fewer places where code jumps back and forth between server-side code and javascript.

When this is finished, it would make it easier to make gui changes as well.  None of the server code will rely on any specific presentation.

Advertisements

2 Responses to Converting from xajax + jQuery to just jQuery

  1. It’s amazing what a good separation of data/business logic/view will do for maintainability of a project! Personally, I’ve been doing all my new web stuff with Google Web Toolkit (http://code.google.com/webtoolkit/), where you write all of your code in Java and it gets compiled to JavaScript! It’s actually quite an amazing process.

    It has a built-in RPC component, but it requires a Java server–but you can ditch it to make custom calls to scripts on your server. After I got the hang of it, I started to really, really like it (isn’t that always the way?)

    I also started using Eclipse (the Java version) for all my GWT coding. Still deciding what editor I’m going to use for PHP, etc.

    • Lytithwyn says:

      I really enjoy using Eclipse as a PHP editor. It’s even smart enough to give you code completion on javascript as well!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: