How to get the next result for the right paginating - javascript

I need to know how to use exactlly the paginating function.
I have read that offest isn't the only way, and there an many ways to paginating between the results.
I would like to paginating without reload the site it's possible?
I got this example
SELECT * FROM Table LIMIT 100, 5000
I expect to put it in a function or in <a> or in button + Eventlistener...
I don't get it how to displaying the next number of result and next on.
Hope what i try to explain is clear.
Thx for the help.

If you are using classic asp indeed, then you can make use of the recordset pagination features.
You might want to have a look at this tutorial: ADO Recordset paging in ASP

Related

Effect on page operation if page is too big in HTML

In one of my requirements, I get the log file (can be around 10MB) from my WebServer, and display a table with its content as log entries (using javascript). The problem I face is that it creates too many table rows, due to which page becomes less responsive.
I want to know if too many objects in HTML makes a page slow ?
Also, what should be workaround for this ?
Thanks in advance.
What does your javascript look like? Depending on how you're building the DOM, it could be the bottleneck. For example:
var html = [];
for(var i=0;i<rows.length;i++) {
html.push('<tr><td>' + rows[i] + '</td></tr>');
}
$('#tbody').append(html.join(''));
is going to be a lot faster than
for(var i=0;i<rows.length;i++) {
$('#tbody').append('<tr><td>' + rows[i] + '</td></tr>');
}
This is assuming you're using jquery. Also, as others have mentioned, use pagination to keep limit the number of elements on the screen.
If your HTML is complex, you may want to look into a template engine, and some help choosing the one that is right for you. I use dust because linkedin did all the hard evaluation work.
So, given this is an AJAX call I see a few options (in order of best performance):
Add paging to the service call and allow the AJAX query to only pull down specific batches of entries. Then implement next/previous page buttons that would make successive calls to retrieve more/less information. e.g. /ajax/log would be your initial call, then clicking next button would call /ajax/log?page=2; Previous button re-calls /ajax/log?page=1.
Pull all the data down in a single call, but only selectively output it to the DOM. KnockoutJS makes ouputting information in a paging format very simple (and there are examples here on Stackoverfow).
Dump it as-s and add a script like jQuery DataTables. This will hide rows and implement paging based on what's been pushed in to the table itself. It requires very little additional programming other than load up the table via ajax, then call $('mytable').datatable().

How to auto update a table using AJAX?

I need to use AJAX to request a random string of 10 numbers from an asp page, delimited by "||" and then display the results on a table.
However the table can only show the top 10 results, and as a new row is added the bottom row should be bumped.
I have done this but what i dont know is how i will use AJAX to automatically update the results on the table, without me having to manually refresh.
im not to use jQuery
First of all, if you really don't want to use a JS framework, you'll have to look to the XMLHttpRequest() object. To poll on a regular interval, you use the good-ol' setTimeout() and for DOM manipulation start out with getElementById() and Node.lastChild property.
Start playing around with those and ask some specific questions if you get stuck.

customizing a table sort - classic ASP

I must sort a table according to the header clicked (only two columns) by the user. The info is coming from a DB and then Im filling an array, the two sorting routines are working pretty well and I basically need to enable both sorting methods at a time.
I guess I should code a few javascript lines in the header, a kind of,
ID
And use some variable in ASP to catch the value changed from javascript but I don't know how achieve that. Handling a session won't work because it is on server side.
Any ideas or suggestions are welcome.
Ps. I'm looking into TableSorter JQuery Plugin but it looks lot more than I need and that implies to learn JQuery, I'd like to use a simplest method.
You could change your link to something like this -
ID
Then in your code behind check for the QueryString parameter and sort your table accordingly. Something like -
If Request.QueryString("sort") = "id" Then
'perform sort by id
ElseIf 'other sort logic
End If

jQuery pagination for json results

What is the best way of doing a pagination? I would also need to save the current page, so that when I click a link it would save the page I was on. So if I'm on page 2 of the pagination and click one link and then get back to pagination page it would remember that I was on page 2.
I get the results/data from Json request where I have offset and limit possibility.
$.getJSON(base_url+'/ajax/get_news/4/!OFFSET!/!LIMIT!/true', func...
Where !LIMIT! is how many results it shows and !OFFSET! is, well offset :D When I click a link, it makes that request, it goes throught the results and appends the result into page.
What is best way to save the page, cookies? Should I get all the results and then do the pagination somehow or do new request when user change page?
Some tutorial or "hands on" example would be awesome. Normal instructions/guides are difficult to undestand since my first language isn't english.
It appears you have two questions:
1) How to save page state (what page you are on): If the application must continue to use an ajax, then you should look at storing the state in the url as discribed here:
http://ajaxpatterns.org/Unique_URLs
2) Regarding where to do the pagination, I think it would depend on the size of the data to paginate. If it is small and you are not worried about the data changing on between paging, do it all in javascript. Otherwise, do it server-side.
Okey I should use the !OFFSET! and !LIMIT! to do the pagination. I just need change those numbers with pagination links (1 2 3 4 pages etc) to get the pagination to work I believe. But I dont know where to start :/

Classic ASP Auto Suggest Like Google

While working on a project i came across a functionality in which i need to implement auto suggest textbox using classic asp. I did it and it works fine. I'm using XMLHttp Request object to pick the database column values when user enter something in textbox.
Everything works fine. But if the table have too many rows (37,000+) in it, the performance of the application decreases. Please suggest what steps should i take in order to improve the performance in this case.
why not just showing a SELECT TOP 15 [name] ...?
why do you need to show them all...
if someone enters "B" I really (as a user) don't expect you (the application) to show me all the possibilities.
...or am I wrong?
P.S. you need to start using something like jQuery ... in around 10 lines you would do the same as all your javascript code ;-)
added
It is normal to have the auto suggest box only start suggesting after the first 3 characters been typed ... try this first!
just add in your showHint method
if (str.length < 3) return;
Use indexes on the database fields that you have in your where-statement in the query and it will go much faster.

Categories