Jump to content

AJAX on Forms


bdmovies

Recommended Posts

I am working on an intranet web app that will not be exclusively inside of a company. I have several different forms that get rather large (Up to 26 different fields). I know the most logical thing to do would be to throw that into a big long variable and just do an insert into the DB once the user has hit Submit. But I am also looking for speed. I want a cornerstone of the app to be it's quickness. So I was thinking, why not make an AJAX MySql insert after every onBlur? Everytime the user is done inputting that field, as soon as he tabs off that particular field gets inserted (after a brief validation). This quickens the insert on the "Submit" button. My question is will it slow down the overall speed of other users (Office staff under 10 in size) who may not be on that same page. For instance, will the fact that 1 user is running 26 queries in a matter of say 2 minutes slow the overall speed of the app?

 

I know there are some big steps needed to ensure proper insertion (i.e. making sure that every insert goes to the proper row. I was thinking on page load, a random key gets generated, using A-Z, a-z, 0-9 and the time and date and store it in a variable on the page and insert that into a new row on the DB. That way, when the 15, 16 21, whatever field gets inserted, it uses that random_key that's on the page to do an UPDATE where page random key = db_random_key; then upon exit - a much prettier serialID gets created 200800001 200800004..etc etc.... and gets inserted as the regular identifier and the random_key gets deleted. I use the 200800001 as a reference number throughout the program, heck of a better UI than 11948fjebJJEIE3quwnv79cbwkgu37hsdrt8@13:99)

 

These are just thoughts, any suggestions?

 

Thanks.

Link to comment
Share on other sites

I think all of that would defeat the purpose of speeding it all up.  As far as I know (don't quote me on this though), you are better off using a single query over multiple queries.  But in your case, you're talking about doing a query each time they tab out of each field.  One problem with this is what if they made a mistake?  It will just add to the queries.

 

You could check yourself by running a benchmark.  Try 100 queries inserting 1-100 each in it's own row.  Then try a single query doing the same.

 

My suggestion would be to use a single query at the end.  I'm no MySQL pro though.

Link to comment
Share on other sites

A usual bottleneck is the communication between the application and the database, and MySQL or whatever here doesn't play any role. So doing 26 queries from one form will load your server for nothing.

Sometimes your user will have the feeling it's fast, sometimes not because of the latency of the server. I suggest your to do this the usual way: one insert/update with all the information per submit.

Link to comment
Share on other sites

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.