Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Web page question. Populating user data in a page.?

I have a web page in a microprocessor that needs to show the current user settings in the micro (the settings can be changed through the page also, but Im good with that part). I have it working, but I was wondering if there is a better way of doing it. Im fairly new to HTML/Javascript, and as far as I can tell, I can only use GET or POST messages from the page to the micro.

What I do now is send the page out, and when its loaded, send a POST message requesting the data. When the data is received by the page, it populates the fields.

So in the web page I have this:

window.onload=getdata;

function getdata(){

... im skipping some code here because it doesnt matter

var u="setup.cgi?sid="+Math.random();

r.open('POST',u,true);

r.onreadystatechange=function() {rply(r);};

r.send(v); //v is '0', which I use to indicate I want the user settings

}

Is there a better way? I can only use HTML and Javascript as far as I can tell. I dont know if the RTOS will do any other language, besides I dont know them anyway.

Update:

EDIT: Microprocessor means the web page is in a microprocessor inside a piece of equipment, not a server. The equipment will sit in a remote, unmanned location. It in effect acts as the server side though.

Like I said, im fairly new to HTML/Javascript, and used some example code as a rough guide to create the web page. The POST message was originally a GET message, but I changed to POST so as to "hide" the actual request data. The "...sid="+Math.random() was in the original sample page, but was used with a GET. I don't know if that makes a difference or not, but regardless, as far as I know, it isn't even looked at by the micro and can be removed.

Errors are handled in the onreadystatechange function, I just didn't show that part because it doesn't have anything to do with the question. I was just wondering if there was a better way to put the user settings in the web page or not. If this is the best way (using HTML/Javascript) then that's fin

Update 2:

EDIT: What I mean is, is there a better way than sending a POST message when the page finishes loading, requesting the user settings, then the server side (the micro) sends the user settings back to the web page where they are displayed.

Update 3:

EDIT: What I mean is, is there a better way than sending a POST message when the page finishes loading, requesting the user settings, then the server side (the micro) sends the user settings back to the web page where they are displayed.

2 Answers

Relevance
  • 8 years ago
    Favorite Answer

    I gather that what you're talking about is using AJAX where the client page, using JavaScript sends a request to the server. I suppose that when you wrote "microprocessor" and "micro" that you're talking about the server.

    I question why you 're using Math.random() I don't understand why you would want this randomness in your URL. sid is a parameter with with get, yet your AJAX request is opening with 'POST'. That seems inconsistent

    I noticed that you have an onreadystatechange handler. I believe that you should handle errors in this function.

    I would have liked to have seen the complete web page. It's hard for me to help you more without the code.

  • Anonymous
    4 years ago

    acceptable imagine i will go back up with is discover ASP and use builtin instructions to fetch the files. in case you could't discover the money for it use own homestead web page write some scripts that could do the job and convert the information to csv and parse them. it will be somewhat straight forward.

Still have questions? Get your answers by asking now.