Announcement

Collapse
No announcement yet.

how to auto refresh a page, and get a callback to postbackproc

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • alexbk66
    replied
    Originally posted by mnsandler View Post
    thanks for this; i'll give it a try
    You can insert variables directly into the string

    Code:
    let eggCount = 20;
    console.log(`On easter we decorted ${eggCount}` easter eggs)

    Leave a comment:


  • mnsandler
    replied
    Originally posted by alexbk66 View Post

    BTW, in JS using Template Literals make string concatenation more readable


    Code:
    let a = 5; b = 10;
    console.log('Sum of %d and %d is %d.', a, b, (a+b));
    [EDIT]

    In C#:

    Code:
    $"[\"{statusmessage}\",\"{gBkUpdate.StatusMessage}\",\"{primaryprogr essmessage}\",\"{gBkUpdate.PrimaryProgressMessage}\"]"
    thanks for this; i'll give it a try

    Leave a comment:


  • mnsandler
    replied
    ie
    Originally posted by alexbk66 View Post

    Can you please provide more code example?
    Here are a few more return values that AjaxPost accepts and responses to:

    refresh the current page; I use this after the user changes a filter select list
    Code:
    Result = "[""PAGE_refresh"",""true""]"

    jump to a new page where NextPage is a variable containing the filename
    Code:
    Result = "[""PAGE_newpage"",""" + NextPage + """]"

    Leave a comment:


  • alexbk66
    replied
    Originally posted by mnsandler View Post
    Return "[""statusmessage"",""" + gBkUpdate.StatusMessage + """,""primaryprogressmessage"",""" + gBkUpdate.PrimaryProgressMessage + """]"
    BTW, in JS using Template Literals make string concatenation more readable


    Code:
    let a = 5; b = 10;
    console.log('Sum of %d and %d is %d.', a, b, (a+b));
    [EDIT]

    In C#:

    Code:
    $"[\"{statusmessage}\",\"{gBkUpdate.StatusMessage}\",\"{primaryprogr essmessage}\",\"{gBkUpdate.PrimaryProgressMessage}\"]"

    Leave a comment:


  • alexbk66
    replied
    Originally posted by mnsandler View Post
    Hey Dirk,
    I got it working with the AjaxPost routine. it accepts a response type from postbackproc that will update divs for you without additional code; which is what i needed for now to get started.
    Can you lease provide more code example?

    Leave a comment:


  • dcorsus
    replied
    Originally posted by mnsandler View Post
    Hey Dirk,
    I got it working with the AjaxPost routine. it accepts a response type from postbackproc that will update divs for you without additional code; which is what i needed for now to get started.
    Awesome!

    Leave a comment:


  • mnsandler
    replied
    Hey Dirk,
    I got it working with the AjaxPost routine. it accepts a response type from postbackproc that will update divs for you without additional code; which is what i needed for now to get started.

    Return "[""statusmessage"",""" + gBkUpdate.StatusMessage + """,""primaryprogressmessage"",""" + gBkUpdate.PrimaryProgressMessage + """]"

    Leave a comment:


  • dcorsus
    replied
    Originally posted by mnsandler View Post
    Ultimately, I do want to only refresh a couple of div sections...so I'm all ears.

    I need to be able to get the new div values from my plugin
    If there is a piece of info on the page that you want to update, put a <div></div> tag around it and make sure that <div> has an id that is unique, say <div id="veryuniqueInsteon">.

    So if you now postback every 2 seconds to your plugin, the plugin would verify if that info was changed and if so, the content of that div can be updated without updating the page.
    You make up your own syntax but upon receiving a response, what is crutial is the div id and the new content and then you update it something like the following




    $('#'+idivId).empty();
    $('#'+idivId).append(item.updateDivInfo);

    Leave a comment:


  • mnsandler
    replied
    Ultimately, I do want to only refresh a couple of div sections...so I'm all ears.

    I need to be able to get the new div values from my plugin

    Leave a comment:


  • dcorsus
    replied
    Originally posted by mnsandler View Post
    i think i got it working (at least the POST part). thank you very much
    Glad to help. Not sure over time you want to have your page refreshing all the time, maybe that is not the intent but if you have questions, glad to share some sample code to refresh just div sections

    Leave a comment:


  • mnsandler
    replied
    i think i got it working (at least the POST part). thank you very much

    Leave a comment:


  • dcorsus
    replied
    check upper/lower case, shouldn't be an issue but you never know, especially when you register your link and use of pluginId, your pathname which uses same pluginId, check they are consistently "Insteon" with capital I. Your registration should look something like

    RegisterFeaturePage("Insteon", "statuspage.html", "") and the statuspage.html must be in the \html\Insteon subdirectory

    Leave a comment:


  • dcorsus
    replied
    Just loaded your html file. I had to rename it to something I have registered with HS (including your links in the javascript and it works here.
    You can click on the entry to see the parameters , inspect the URL .. I think it shows you do send the POST but get no response, so either URL is incorrect or registeration is incorrect.

    Leave a comment:


  • mnsandler
    replied
    ok. i registered the statuspage.html but still not joy. the plugin isn't being called and thus to status
    Attached Files

    Leave a comment:


  • dcorsus
    replied
    Originally posted by mnsandler View Post
    i do register three feature pages using RegisterFeaturePage so they show on HS UI, but i didn't think i needed to register every .html file I use.

    here is the statuspage.html - nothing special

    You do. In R4.2 driven by security issues (or so I understood), HS will not respond to POSTs to a URL that is not registered (actually common sense). If you don't want them to show in your menu, register them linkText ="" You should see a message going out if you use the browser debugger and seem to recall a 404 response. I ran into this when everything working in R41 stopped working in R42, URL must be registered.

    Leave a comment:

Working...
X