Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 40

Thread: web server; sending events and polling lua variables

  1. #21
    Join Date
    Oct 2005
    Posts
    307

    Default

    I've updated the file and tested it! Using the following data, I successfully ran the code on my machine:

    myVal = "12345"
    AD = {['Value'] = {['1']='Hello',['2']=' there',['3']='this',['4']='works!'}}

  2. #22
    Join Date
    Aug 2004
    Location
    The Netherlands (Norg, near Assen)
    Posts
    625

    Default

    Strange thing. It works fine on my iPhone and iPad (thank you) but not in IE8.I get the error :
    Code:
    Foutdetails webpaginaGebruikersagent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)Tijdstempel: Fri, 10 Feb 2012 09:39:59 UTC Bericht: Id, tekenreeks of getal wordt verwachtRegel: 26Teken: 4Code: 0URI: http://server.x.nl:9/test.lhtml
    This means 'id, string or number is expected'.Because it also should work on my PC some more help is appreciated. I Googled on the problem and saw more people having this kind of erros on IE8 but no solution. Many times it seems to be a litte syntax problem; but what and where?Update: I runs fine on IE8 in compatibility mode.

    Problem was an extra ,

    Code:
      function checkGIRDER() {
       $.ajax({
        type: "GET",
        url: "ajaxreqjson.lhtml",
        data: {Data : "myVal,AD.Value"},
        async: true,
        cache: false,
        timeout:5000,
        success: function(data){
         checkDATA(data);
         setTimeout('checkGIRDER()',1000);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown){
         $("#error").text("Comet Timeout ERROR: " + textStatus + " (" + errorThrown + ")");
         setTimeout('checkGIRDER()',1000);
        },<<<---
       });
      }
    The , before the <<<--- had to be removed.
    Last edited by VSDomotics; February 10th, 2012 at 05:11 AM. Reason: Found problem
    Geert

  3. #23
    Join Date
    Oct 2005
    Posts
    307

    Default

    That is funny because I copied that from another project I was working on, saw the comma, took it out, put it back, didn't see any difference (It works fine on everything for me, but I don't run IE.), so I kept it in (thinking the sample was correct)...

    Anyway, glad it is working. Let me know if you need more help...

  4. #24
    Join Date
    Aug 2004
    Location
    The Netherlands (Norg, near Assen)
    Posts
    625

    Default

    It is getting more and more clear thank to your help. I have atill another question. Do you think is is possible to retrieve a single array element and not the entire array?

    I like to retrieve for instance 'AD.Value[15]'. So an array element with a numeric index. I mean only this element and not retrieve the whole array and then selecting one key (for the sake of minimal data transfer).
    Geert

  5. #25
    Join Date
    Oct 2005
    Posts
    307

    Default

    Yes, it is possible. Just change the variable(s) sent in the Ajax request to include what you want AND change the success function so it doesn't try to loop through the keys. You can also return the entire table and only reference a single key on the client side vs. looping through all the keys like my example does.

    You can also loop through all the keys, test if an element exists (you have to make 'smart' element ids like the example) on the client side and only update that particular one. I do that for my lighting. On startup or reset, Girder queries my lighting controller for scenes I specifically want to have the state available. As the the system gets used, all scenes are broadcast as they change, so even the ones I don't use get added to my table. The webpage requests the entire table and I loop through them all only updating the ones I have controls for on the page...

  6. #26
    Join Date
    Aug 2004
    Location
    The Netherlands (Norg, near Assen)
    Posts
    625

    Default

    I know I can select one value from a completely retrieved array. The point is how I can retrieve just one value from the array. I can't manage to make a query so I can selct this single value. I tried:
    "AD.Value.1"
    "AD.Value[1]"
    and some more variations. But how to compare AD.Value[1] against the Girder _G table?
    I hope you can help.
    Geert

  7. #27
    Join Date
    Oct 2005
    Posts
    307

    Default

    Below is the correct syntax for the data structure I posted:

    data: {Data : "myVal,AD.Value,AD.Value['1']"},

    $("#test").text(jsonOBJ["AD.Value['1']"]);

  8. #28
    Join Date
    Aug 2004
    Location
    The Netherlands (Norg, near Assen)
    Posts
    625

    Default

    This only works (I think) because you both have "AD.Value" and "AD.Value['1']" in the request. So the complete array is retrieved and after that only index 14 selected.
    Code:
    data: {Data : "myVal,AD.Value,AD.Value['1']"}
    ,When you only request
    Code:
    data: {Data : "myVal,AD.Value['1']"}
    ,it does not work. Am I missing something?
    Geert

  9. #29
    Join Date
    Oct 2005
    Posts
    307

    Default

    It works either way for me. Did you remove the for loop? Are you sure your data is formatted the same way my example is? What error(s) are you getting?

  10. #30
    Join Date
    Aug 2004
    Location
    The Netherlands (Norg, near Assen)
    Posts
    625

    Default

    This is the error I get:
    Cannot read property '14' of undefined[{"CV.VacationMode":false,"CV.VacationTemp":16,"CV. RoomTempWanted":20.5,"CV.DayTemp":21.5,"CV.NightTe mp":20.5,"CV.PowerMode":"Auto","CV.NightLow":true, "CV.AutoNight":true,"CV.NightTemp":20.5,"CV.Moduli neOn":false,"AD.Value['14']":"[Variable Not found]"} ]
    Geert

Page 3 of 4 FirstFirst 1234 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •