General thoughts on custom AJAX

Associate
Joined
8 Aug 2008
Posts
302
I've got two different styles of script I modify for sites.

One has an opening and closing connection function separately that the 'middle' functions if you like use to pass data back and forth, which seems the most solid but the trouble is with multiple functions on the page, I have to output an identifier at the start of the response text so that the code that handles the response text knows what to do with it which is a bit messy.

The other just has the opener and handles the passing of the data out and the data coming back inside each function. It results in more code as there's more setup for each function but means the function sending the data to the external php file handles the data that comes back without as much fuss.

Schools of thought?

Sorry if I've rambled incoherently...
 
What exactly are you doing with the in/out data? It sounds like you aren't using a JavaScript framework, personally I'd just use jQuery's AJAX system, it'll save you a tonne of time and you won't have to bother so much about the inner workings of your requests.
 
General school of thought is to use a library. Chances are, 99% of people wouldn't write something as efficient as jQuery's implementation and it takes 2 secs to use. A guy I used to work with did all his own javascript until I showed him jquery and since then he hasnt looked back.
 
Back
Top Bottom