473,382 Members | 1,165 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Use jquery to retrieve a lot of data

Hey guys I created this chat system that used to work fine till number of messages increased (over 300 messages and i want it to take up to 1000)started to cause slow script and takes time to retrieve all data. The idea depends on selecting the data XML style and then add it to a specific tab and repeat the act with setTimeout,is there any other way i can do i really need ideas and here is my code.
Expand|Select|Wrap|Line Numbers
  1.  function updateMessage()
  2.  {
  3.   $.post("db.php",
  4.   {MsgNo :$("#no_of_msgs").val()},
  5.   function(data)
  6.  {
  7.    $(data).find("message").each(function() {
  8.    var msg_id = $(this).find("msg_id").text();
  9.    var date_time = $(this).find("date_time").text();
  10.    var from_user = $(this).find("from_user").text();
  11.    var from_user_id = $(this).find("from_user_id").text();
  12.    var from_group = $(this).find("from_group").text();
  13.    var to_user = $(this).find("to_user").text();
  14.    var to_user_id = $(this).find("to_user_id").text();
  15.    var to_group = $(this).find("to_group").text();
  16.    var msg_type = $(this).find("msg_type").text();
  17.    var msg = $(this).find("msg").text();
  18.    var from_grp_abr = $(this).find("from_grp_abr").text();
  19.    var to_grp_abr = $(this).find("to_grp_abr").text();
  20.    var flagged = $(this).find("flagged").text();
  21.    var onlydate = getonlydate(date_time);
  22.    $("#no_of_msgs").val(msg_id);
  23.  
  24.    if (from_group == $("#login").val())
  25. {
  26.  var reply = '';
  27. }
  28. else {var reply = 'reply';}
  29.  
  30.    if(from_user == "")
  31.    {
  32.     var handle_reply = from_grp_abr;
  33.    }
  34.    else 
  35.    {
  36.     var handle_reply = from_user;
  37.    }
  38.  
  39.    var html = "<tr id='row_"+msg_id+"'>";
  40.    html += "<td><a class='bullet' onclick='changeStatus(\""+msg_id+"\")'>&nbsp;<\/a><\/td>";
  41.    html += "<td><a class='"+reply+"' onclick=\"reply('"+escape(handle_reply)+"','"+escape(to_user)+"',"+from_user_id+","+to_user_id+");\">  <\/a><\/td>";
  42.     html += "<td class='time'>"+date_time+"<\/td>";
  43.      html += "<td>"+from_user+"&nbsp;["+from_grp_abr+"]"+"<\/td>";
  44.      html += "<td>"+to_user+"&nbsp;["+to_grp_abr+"]"+"<\/td>";
  45.      html += "<td><a href='#' class="+msg_type+"><\/a><\/td>";
  46. html += "<td><a id='flag_"+msg_id+"' class='"+class_flag+"' onclick='flagMsg("+msg_id+")'>  <\/a><\/td>";
  47.          html += "<td>"+msg+"<\/td>";
  48.          html += "<td>"+from_grp_abr+"<\/td><\/tr>";
  49.  
  50.            $('#no_of_msgs').val(msg_id);
  51.  
  52.   $("#tbody1").prepend(html);
  53. updatetabledata('t1');
  54. alternateRows('t1');
  55.  //append data to tab2 messages received
  56.     if (to_group == $("#login").val())
  57.     {
  58.          $("#tbody2").prepend(html);
  59.          updatetabledata('t2');
  60.          alternateRows('t2');
  61.       }
  62.    //append data to tab3 sent messages
  63. else if (from_group == $("#login").val())
  64.    {
  65.    $("#tbody3").prepend(html);
  66.    updatetabledata('t3');
  67.    alternateRows('t3');
  68.   }
  69.  
  70.    if(from_group != $("#login").val())
  71.   {
  72.    $("#tbody"+from_group).prepend(html);
  73.    updatetabledata('t'+from_group);
  74.    alternateRows('t'+from_group);
  75.   }
  76.    if(to_group != $("#login").val())
  77.   {
  78.    $("#tbody"+to_group).prepend(html);
  79.    updatetabledata('t'+to_group);
  80.    alternateRows('t'+to_group);    
  81.   }
  82.     });
  83.  });
  84.    setTimeout('updateMessage()',3000); 
  85.  }
  86.  
I am thinking the problem is for using each() and then distributing the data over several tabs at same time any ideas.
Apr 13 '10 #1
0 1404

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Don Quijote de Nicaragua | last post by:
Hi, is there any way to insert a registration in SQL Server using Jquery en ASP.NET.
1
by: mikeh3275 | last post by:
I'm new to developing in jQuery, so I'm probably doing this wrong. I'm loading a form into a modal dialog box and I'm trying to assign a click event to the button in the form, but I can't seem to...
83
by: liketofindoutwhy | last post by:
I am learning more and more Prototype and Script.aculo.us and got the Bungee book... and wonder if I should get some books on jQuery (jQuery in Action, and Learning jQuery) and start learning about...
9
by: Jon Paal [MSMD] | last post by:
using json like ( {"Records": , "RecordCount":"1" } ) and jquery like: $.ajax({ .... success: function(json, status) {
20
by: Aaron Gray | last post by:
There does not seem too be anyway to test if two jQuery references are the same element. Given :- ... <div id="1"></div .... Then :- alert( $("#1") == $("#1"))
26
by: RobG | last post by:
Do some of the regulars here need to re-think their (sometimes strident) opposition to libraries? Both Microsoft and Nokia have announced support for jQuery. It seems to have gained quite a bit...
53
by: souporpower | last post by:
Hello All I am trying to activate a link using Jquery. Here is my code; <html> <head> <script type="text/javascript" src="../../resources/js/ jquery-1.2.6.js"</script> <script...
2
by: sarah aziz | last post by:
Hello all I am trying to retrieve the data from mysql database by php to plot a flot graph can anyone help me please this is all i have done for now Php $sql = mysql_query("SELECT count(Msg_ID)...
25
pradeepjain
by: pradeepjain | last post by:
<html> <head> <script src="jquery.js" type="text/javascript"></script> <script src="jquery.rating.js" type="text/javascript" language="javascript"></script> <link...
5
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.