Jump to content

Best practices question: using AJAX + JQUERY to update content in <div>


Recommended Posts

I'm fairly new to using AJAX and JQUERY to call back to the server, process a form's contents, and then update a div file accordingly.  This new project has almost everything in a single div (id="mainContent").  This is the <div> that I will be updating through the ajax call.

 

My div has a lot of different hyperlinks at the moment (text, image, and form submit button).  I know how to do an update for a page that has a single form with a single submit button.  In order to turn my site into an ajax driven site, should I take all these image links and wrap individual forms around them?  What about the text links?  It all seems very cumbersome and I'm curious how you experts would tackle the issue.

 

Any assistance on best practices would be greatly appreciated!  Thanks in advance.

 

 

In order to turn my site into an ajax driven site, should I take all these image links and wrap individual forms around them? What about the text links?

Definitely not. You shouldn't be adding any extra markup at all for AJAX. What you need to do is add onclick listeners to each of your links, with a javascript function that will call the data from the server when those links are clicked.

 

It all seems very cumbersome and I'm curious how you experts would tackle the issue.

It is definitely cumbersome, which is why you see few sites that are fully ajax driven. I did my site fully ajax, but it was a lot of work to set it all up to work properly, and I've been using Ajax for near 5 years now.

 

Good luck!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.