[jQuery] Re: Scoping issue with load and call back function.

2009-05-08 Thread Stever

Josh and all,

I figured out a way around the issue using the ajaxStop function.
The ajaxStop event is triggered when all outstanding requests (load in
this case) are complete.
When this happens all the tables I wish to load are loaded to the
document.

My original code was trying to grab information with the load callback
function and store in a global variable.
This will not work.

Instead, I load the desired pages to a hidden element. Then when the
pages are loaded (ajaxStop event triggered), I can then process the
tables and pull out the desired information and build a new table.


There may be a better way to do this, perhaps on the server side
rather than on the client in the document. But at the moment this is
what I need.

Thanks for the help.



$('#display_merge').ajaxStop(function() {

};


On May 7, 12:31 pm, Josh Nathanson joshnathan...@gmail.com wrote:
 Well it's a little tricky because of the asynchronicity.  The way I might
 handle it is to set some kind of isLoaded global object that gets
 poplulated each time an async call returns.  You more or less already have
 that.  Then, create a polling function using setInterval or setTimeout
 that checks every 500ms or so to see if that isLoaded object is completely
 populated.  Once you determine that it is, then generate the combined table.

 -- Josh

 -Original Message-
 From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On

 Behalf Of Stever
 Sent: Thursday, May 07, 2009 4:28 AM
 To: jQuery (English)
 Subject: [jQuery] Re:Scopingissue with load and call back function.

 Josh,

 First the firstload=0 and not resetting the variable was left off. But
 ultimately is unrelated to the asynchronous problem you pointed out.

 Asynchronous loading makes a big difference here.  As a pretty recent
 user of jquery, I obviously designed this code wrong.

 So here is what I what to do.   I have multiple web pages on a server
 that have summary result tables for different products.
 I want to read each of these summary tables and combine the results
 into one single table.

 My thought was to use Jquery Load to load each table and read the
 information and store into the global arrays, TableCell, TableRow and
 TableColumn.

 Apparently this approach is flawed.

 Can you or someone on this group recommend/outline a way to accomplish
 this relatively simple task?

 Thanks!!

 Steve

 On May 6, 7:13 pm, Josh Nathanson joshnathan...@gmail.com wrote:
  OK it looks like you have a few things to sort out here.

  One thing is that you have to remember that load is asynchronous.  So when
  that is fired the rest of your code will continue along its merry way.  In
  other words the loop will keep looping independent of the callback
 function
  firing.  My hunch is that this will give you unexpected values for the
  variable [i] in the load callback function.  Because of this you will
  probably have to do some refactoring to get the results you're looking
 for.
  Not sure though if you intend to run that load on every iteration of the
  loop or just the first one.

  Also you may have left this out, but I see you have a firstload = 1
  declaration, but then you don't set it to 0.  This could also be messing
 up
  your results as it will run every time unless you set it to 0 somewhere.

  Definitely leave the variable declarations outside document ready as in
 your
  second email.

  -- Josh

  -Original Message-
  From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On

  Behalf Of Stever
  Sent: Wednesday, May 06, 2009 4:31 PM
  To: jQuery (English)
  Subject: [jQuery] Re:Scopingissue with load and call back function.

  Josh thanks for the quick response.

  I tried putting the variables

  var TableCells    =[,];
  var TableRowName  =[,];
  var TableColName  =[,];
   outside the document ready function.  Originally. (not redefined with
  var inside document ready shown here).

  script type=text/javascript src=http://www.hou.asp.ti.com/
  sparcit_data_reports//js/jquery.js/script
  script type=text/javascript
  var devList  = [
                  PART_1
                 ];

  var TableCells    =[,];
  var TableRowName  =[,];
  var TableColName  =[,];

  $(document).ready(function(){
    $.ajaxSetup({cache: false}) ;
    var firstLoad = 1;
    for( var i =0; i  devList.length; i++)
    {
      // set the path
      var path = url + devList[i] ;
     var colName =[];
     var rowName =[];
     var cellValue = [];

      //load the page but collect the table info
      if (firstLoad == 1)
      {
        $('#display').load(path,
           function(){
                               manipulate tables and put data in Global
  Array

                                    TableCells[i]   = cellValue;
                                    TableRowName[i] = rowName;
                                    TableColName[i] = colName;

        });
         var lenTable2 = TableColName[i].length;

      }
    }

  });

  So where I

[jQuery] Re: Scoping issue with load and call back function.

2009-05-07 Thread Stever

Josh,

First the firstload=0 and not resetting the variable was left off. But
ultimately is unrelated to the asynchronous problem you pointed out.

Asynchronous loading makes a big difference here.  As a pretty recent
user of jquery, I obviously designed this code wrong.

So here is what I what to do.   I have multiple web pages on a server
that have summary result tables for different products.
I want to read each of these summary tables and combine the results
into one single table.

My thought was to use Jquery Load to load each table and read the
information and store into the global arrays, TableCell, TableRow and
TableColumn.

Apparently this approach is flawed.

Can you or someone on this group recommend/outline a way to accomplish
this relatively simple task?

Thanks!!

Steve










On May 6, 7:13 pm, Josh Nathanson joshnathan...@gmail.com wrote:
 OK it looks like you have a few things to sort out here.

 One thing is that you have to remember that load is asynchronous.  So when
 that is fired the rest of your code will continue along its merry way.  In
 other words the loop will keep looping independent of the callback function
 firing.  My hunch is that this will give you unexpected values for the
 variable [i] in the load callback function.  Because of this you will
 probably have to do some refactoring to get the results you're looking for.
 Not sure though if you intend to run that load on every iteration of the
 loop or just the first one.

 Also you may have left this out, but I see you have a firstload = 1
 declaration, but then you don't set it to 0.  This could also be messing up
 your results as it will run every time unless you set it to 0 somewhere.

 Definitely leave the variable declarations outside document ready as in your
 second email.

 -- Josh

 -Original Message-
 From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On

 Behalf Of Stever
 Sent: Wednesday, May 06, 2009 4:31 PM
 To: jQuery (English)
 Subject: [jQuery] Re:Scopingissue with load and call back function.

 Josh thanks for the quick response.

 I tried putting the variables

 var TableCells    =[,];
 var TableRowName  =[,];
 var TableColName  =[,];
  outside the document ready function.  Originally. (not redefined with
 var inside document ready shown here).

 script type=text/javascript src=http://www.hou.asp.ti.com/
 sparcit_data_reports//js/jquery.js/script
 script type=text/javascript
 var devList  = [
                 PART_1
                ];

 var TableCells    =[,];
 var TableRowName  =[,];
 var TableColName  =[,];

 $(document).ready(function(){
   $.ajaxSetup({cache: false}) ;
   var firstLoad = 1;
   for( var i =0; i  devList.length; i++)
   {
     // set the path
     var path = url + devList[i] ;
    var colName =[];
    var rowName =[];
    var cellValue = [];

     //load the page but collect the table info
     if (firstLoad == 1)
     {
       $('#display').load(path,
          function(){
                              manipulate tables and put data in Global
 Array

                                   TableCells[i]   = cellValue;
                                   TableRowName[i] = rowName;
                                   TableColName[i] = colName;

       });
        var lenTable2 = TableColName[i].length;

     }
   }

 });

 So where I try to access the new length of TableColName[i]  I get that
 this variable is undefined.

 Actually while debugging, I find that variable i defined in the loop
 outside the load, is NOT available inside the load function.

 It is all very confusing.

 :-(

 On May 6, 6:10 pm, Josh Nathanson joshnathan...@gmail.com wrote:
  When you say you get undefined outside the load function, do you mean
  outside $(document).ready, or inside $(document).ready?

  They should not be accessible outside document.ready, because of the
 closure
  caused by passing the anonymous function to document.ready, and because
 you
  use var to declare them inside that function.

  If you want them to be accessible globally, you'll have to declare them
  outside document.ready.

  -- Josh

  -Original Message-
  From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On

  Behalf Of Stever
  Sent: Wednesday, May 06, 2009 3:54 PM
  To: jQuery (English)
  Subject: [jQuery]Scopingissuewith load and call back function.

  I am a relative newbie to Jquery and I am getting somescopingissues
  I can't figure out.

  I was hoping for some advice.

  Basically I am trying to load multiple documents that have HTML tables
  and then parse the tables and redisplay in a new format. Merging
  elements from the different documents.

  So basically I build the url path for a set of devices  and load
  them. I thought in the load function I could collect elements into
  global variables and manipulate in the final document. But is not
  working.

  The variables TableCells, TableRowName and TableColName are what I
  haveissueswith.

  $(document).ready

[jQuery] Scoping issue with load and call back function.

2009-05-06 Thread Stever

I am a relative newbie to Jquery and I am getting some scoping issues
I can't figure out.

I was hoping for some advice.

Basically I am trying to load multiple documents that have HTML tables
and then parse the tables and redisplay in a new format. Merging
elements from the different documents.


So basically I build the url path for a set of devices  and load
them. I thought in the load function I could collect elements into
global variables and manipulate in the final document. But is not
working.

The variables TableCells, TableRowName and TableColName are what I
have issues with.


$(document).ready(function(){
  $.ajaxSetup({cache: false}) ;

  var TableCells=[,];
  var TableRowName  =[,];
  var TableColName  =[,];

 for( var i =0; i  devList.length; i++)
  {
// set the path
var path = prefix + yield_dir + devList[i] +'/' + smslot_yield;
//clear the display area
$('#display').html();

   var colName =[];
   var rowName =[];
   var cellValue = [];

//load the page but collect the table info
if (firstLoad == 1)
{

  $('#display').load(path,
   function(){


 manipulate tables and put data in
Global Array
  TableCells[i]   = cellValue;
  TableRowName[i] = rowName;
  TableColName[i] = colName;


});
}
  }
});



So the variables are defined in the document ready scope. (I even
tried outside that as well)
 var TableCells=[,];
 var TableRowName  =[,];
 var TableColName  =[,];

I set these variables in the load function scope and they are
accessible there and work fine.

However when I try to access outside the load function the variables
are undefined.

Can you tell what I am missing?

Thanks,

Steve


[jQuery] Re: Scoping issue with load and call back function.

2009-05-06 Thread Stever

Josh thanks for the quick response.

I tried putting the variables

var TableCells=[,];
var TableRowName  =[,];
var TableColName  =[,];
 outside the document ready function.  Originally. (not redefined with
var inside document ready shown here).


script type=text/javascript src=http://www.hou.asp.ti.com/
sparcit_data_reports//js/jquery.js/script
script type=text/javascript
var devList  = [
PART_1
   ];

var TableCells=[,];
var TableRowName  =[,];
var TableColName  =[,];

$(document).ready(function(){
  $.ajaxSetup({cache: false}) ;
  var firstLoad = 1;
  for( var i =0; i  devList.length; i++)
  {
// set the path
var path = url + devList[i] ;
   var colName =[];
   var rowName =[];
   var cellValue = [];

//load the page but collect the table info
if (firstLoad == 1)
{
  $('#display').load(path,
 function(){
 manipulate tables and put data in Global
Array

  TableCells[i]   = cellValue;
  TableRowName[i] = rowName;
  TableColName[i] = colName;

  });
   var lenTable2 = TableColName[i].length;

}
  }

});


So where I try to access the new length of TableColName[i]  I get that
this variable is undefined.

Actually while debugging, I find that variable i defined in the loop
outside the load, is NOT available inside the load function.

It is all very confusing.

:-(



On May 6, 6:10 pm, Josh Nathanson joshnathan...@gmail.com wrote:
 When you say you get undefined outside the load function, do you mean
 outside $(document).ready, or inside $(document).ready?

 They should not be accessible outside document.ready, because of the closure
 caused by passing the anonymous function to document.ready, and because you
 use var to declare them inside that function.

 If you want them to be accessible globally, you'll have to declare them
 outside document.ready.

 -- Josh

 -Original Message-
 From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On

 Behalf Of Stever
 Sent: Wednesday, May 06, 2009 3:54 PM
 To: jQuery (English)
 Subject: [jQuery]Scopingissuewith load and call back function.

 I am a relative newbie to Jquery and I am getting somescopingissues
 I can't figure out.

 I was hoping for some advice.

 Basically I am trying to load multiple documents that have HTML tables
 and then parse the tables and redisplay in a new format. Merging
 elements from the different documents.

 So basically I build the url path for a set of devices  and load
 them. I thought in the load function I could collect elements into
 global variables and manipulate in the final document. But is not
 working.

 The variables TableCells, TableRowName and TableColName are what I
 have issues with.

 $(document).ready(function(){
   $.ajaxSetup({cache: false}) ;

   var TableCells    =[,];
   var TableRowName  =[,];
   var TableColName  =[,];

  for( var i =0; i  devList.length; i++)
   {
     // set the path
     var path = prefix + yield_dir + devList[i] +'/' + smslot_yield;
     //clear the display area
     $('#display').html();

    var colName =[];
    var rowName =[];
    var cellValue = [];

     //load the page but collect the table info
     if (firstLoad == 1)
     {

       $('#display').load(path,
                                function(){

                                  manipulate tables and put data in
 Global Array
                                   TableCells[i]   = cellValue;
                                   TableRowName[i] = rowName;
                                   TableColName[i] = colName;

                                 });
     }
   }
 });

 So the variables are defined in the document ready scope. (I even
 tried outside that as well)
  var TableCells    =[,];
  var TableRowName  =[,];
  var TableColName  =[,];

 I set these variables in the load function scope and they are
 accessible there and work fine.

 However when I try to access outside the load function the variables
 are undefined.

 Can you tell what I am missing?

 Thanks,

 Steve


[jQuery] A problem setting timeout feature in AJAX.

2009-04-23 Thread Stever

Hello,

I have a jquery HTML page which loads a form.

The form has a bunch of settings, but eventually the form gets
submitted using a post command (see below) which returns and HTML
page which was built by a script running on the server.

This works fine, except when the script runs longer than 5 minutes.
The post command just returns nothing.

I tried using the timeout command in the high level page as follows:

  $.ajaxSetup({cache: false,
   timeout: 1800 }) ;

But this does not seem to work. Does anyone have a suggestion?


Here is the post command:

$.post('/cgi-bin/tw_lookup_3.cgi', lookupData, function(data){

  // $('#results').load( prefix + user_name + /
TW_LOOKUP_RESULTS.html);
  // $('#results a').attr('target','_blank').css
('backgroundColor','#d5e9d7');
 var page = $(data).find('input[name=result_dir]').val();
 $('#results').load( page + /TW_LOOKUP_RESULTS.html);


 $('#SubmitQuery').attr('disabled',false);
 $('#SubmitQuery').val('Submit Query');
 $('#SubmitQuery').css('backgroundColor','');
 $('#SubmitQuery').css('color','');
},html);












[jQuery] Re: Jquery load not getting updated pages.....

2008-10-22 Thread Stever

Hey everybody.  Thanks for all the help!

I am using the $.ajaxSetup({cache:false})  option.
It works great.

Looks like I need to study up on the ajax functions.

Always more stuff to learn!

Thanks.

Steve




On Oct 22, 2:26 am, 汪杰 [EMAIL PROTECTED] wrote:
 you can set :
 $.ajaxSetup({cache: false})
 or:
 $.ajaxSetup({beforeSend:
 function(e,xhr,s){xhr.setRequestHeader(If-Modified-Since, new Date(0));}})
 or:
 $('#display').ajaxSend(function(e,xhr,s){xhr.setRequestHeader(If-Modified-Since,
 new Date(0));}).load('../forms/test_form_1.html');


[jQuery] Jquery load not getting updated pages.....

2008-10-21 Thread Stever

Hello,

I spent about an hour trying to figure out why a form I was loading to
a web page was not updating.

In my web page I have a navigation button tool, when I click I want to
load a form into the #display div.

$(document).ready(function(){

 .. a bunch of code.

  $('#menu li.tool').click(function() {
$('#display #product').remove();
$('#menu li[device=device]').removeAttr('clicked');
$('#display').load('../forms/test_form_1.html');
  });

.. remaining code 
};


I call up the page and click the tool button and the form displays no
problem.

However, later I made changes to the form (test_form_1.html) and they
were not included, even after refreshing the page.

I even removed the html file and it still loads!

Apparently this file is saved in the cache, how do I make sure
everytime I click on the tool button I get the latest page?

Steve












[jQuery] Re: Jquery load not getting updated pages.....

2008-10-21 Thread Stever

Thanks for the message.

Now I'll show you how new I am at this stuff.   :-)

How do I update the headers. Apparently this is done from the server
side.

Do I need to do something with the load function, (I know you said I
could add a random query statement to the URL in the load), but
obviously that's not updating the headers.

Do I have to do something with the HTML page itself that I am
loading.

I am confused because it seems like the HTTP headers and between the
load and the HTML page.

Thanks again for your help.


Stever


On Oct 21, 1:01 pm, Bil Corry [EMAIL PROTECTED] wrote:
 Stever wrote on 10/21/2008 11:34 AM:

  Apparently this file is saved in the cache, how do I make sure
  everytime I click on the tool button I get the latest page?

 Via the headers, have the page expire in the past and set the cache-control 
 headers to no-cache:

         Expires: Thu, 11 Jun 1998 13:17:30 GMT
         Cache-Control: no-store, no-cache, must-revalidate, no-transform, 
 max-age=0, post-check=0, pre-check=0
         Pragma: no-cache

 Some people instead choose to make the URL dynamic by appending a random 
 query string using the current milliseconds (or something similar).  I don't 
 use that method, so maybe someone who does it that way can respond.

 - Bil


[jQuery] Re: Jquery load not getting updated pages.....

2008-10-21 Thread Stever

Bil,

Thanks for the help.   I think I can figure it out from here.I have
several options

The server is Apache and I am using perl cgi on the server.

However the confusion I have is that on the Jquery load you aren't
using the server get/post methods. You just give it a URL.
And the page I am loading static (pre-built) , well it's a form that
as a get/post method embedded in it.
But the form itself is just a static html file.

Anyway I appreciate the help. Thanks!

Steve







On Oct 21, 6:39 pm, Bil Corry [EMAIL PROTECTED] wrote:
 Stever wrote on 10/21/2008 6:33 PM:

  How do I update the headers. Apparently this is done from the server
  side.

 It depends on your server-side language and web server.  Apache can set 
 headers using mod_headers:

        http://httpd.apache.org/docs/2.0/mod/mod_headers.html#header

 Depending on your server-side language (Lasso, PHP, Python, Perl, etc) you'd 
 have to look it up as it differs per language.

  I know you said I could add a random query statement to the URL in
  the load

 You can do that instead of setting the headers.  Might be easier if you're 
 unsure of how to set response headers.

 - Bil


[jQuery] Web page navigation question....

2008-10-20 Thread Stever

Hello,

I am new to Javascript and Jquery and I have a question on a web page
I am building.

I have an interactive form where I have two columns, one column holds
the form the second holds the results.

When the user comes to the page, the form and the result window are
blank.

The form allows the user to query a database and retrieve information
and the information is displayed in the results window.

So here is my problem.

After the the form is filled out and submited, a cgi script runs and
submits the query to a database and an HTML is generated on the
server.

I have a callback on submit button to display the result page using
the load function.

This works fine.  However on the page that is loaded has links for
more information.

If I drill down to these links. the new information is loaded to the
current browser and not in the result panel.

But not only that if I hit the back button, I go to the original form
page and all the information is blank.

1) How can I go back to the form page with query results?
2) Even better, when I click on the link in the results area, can the
new information be loaded to this area AND have the ability when I hit
the back button to show the previous results?

Thanks for any help or suggestions.

Steve