Wednesday, July 9, 2008

Avoid Server Trip during Edit

Lets think of a scenario--A table full of student information with links for edit,delete and details view--a typical dashboard.Now we want to edit a particular student and clicks on the edit button.A pop up div opens up and shows all informations in a floting div.simple.
Now what most people do to achive this?They call a page in background via AJAX and and populate the floating div with those values.This is all right.

But think again.Are not all the values corresponding to a particular student already present in the page?So why make another server request to fetch the same data again?
Now comes the advanced JavaScript. Have you heard of DOM(Document Object Model) scripting?we will use DOM scripting to achive that.DOM programming is nothing but manipulating HTML controls in a page in simple words.

What will be our methodology?
When the table created we will asssing a unique id for each row." >.
Now on each edit button we will provide that id and studentId(pk of student table).
,);" />
Now when the div pops up via showDiv() function we are passing the row id and studentId.
This row id will help us in fetching the data from the table and studentId will help us in updating data in the database.

Well friends I think if I produce some pictures and real code then it will be easy for you to understand.So read on.............

No comments: