Jump to content
rizwansyed

ajax for webserver

Recommended Posts

Hi

am able to run using XAMPP on PC.

When i run from my board, am not getting proper data.

I mean it is not fetching the file index_1.txt.html and index_1.txt file are available in same path in sd card.

Anything wrong

 

Instead of using second argument with file name, is it possible to use as a function and call it in same file in below code

xhttp.open("POST", "index_1.txt", true);

Please suggest

 

Thanks and Regards

Rizwan Syed

Share this post


Link to post
Share on other sites

(1) Check if board picks up submitted form data

Create a form, submit with text type inputs first name/last name (give them each a default value of 'John' & 'Doe') to board using get or post see if the board is able pick up the submitted data of 'John' and 'Doe'.

If your board can't do this simple basic operation you need to consult with the boards forum to find out HOW TO DO THIS.

AJAX does the same thing BUT! without leaving the page, the form needs method: 'post' or 'get', action: where to send/what file to access, the AJAX parameters need the same. So unless you achieve the same result as using the form, its pointless discussing this further. This is more likely a board 'how to' problem, than anything to do with html, JavaScript or server script.

It like asking a car mechanic how to fix a jet engine, 'I keep pressing the accelerator pedal, but the jet engine doesn't do anything, its like there's no reaction to the accelerator being pressed'

Share this post


Link to post
Share on other sites

Hi Dsonesuk,

Actually form usage i have checked with html.it works fine.

With Ajax am trying to use setInterval("loadDoc()", 1000); as shown in attached figure.

Every 1 sec, i can able to see the data receiving at POST request on board side ( checked through breakpoint).

 

Now in sd card i have kept a file "ajax_info.txt" with some static data in it.But am not getting any data.

 

atest.txt

Share this post


Link to post
Share on other sites

Hi

Now it is able to read the data from my file ajax_info.txt.Only static data present in file am getting.

So now how can i get updated value from my board.

DO i need to write  it continuously   to ajax_info.txt  or any other way to do it.

Edited by rizwansyed

Share this post


Link to post
Share on other sites

At the moment it sounds as though you are continuously reading info from text file, which the board can pick up on? You are not sending data values to the board which the board can pick up, as explain under heading 'POST Requests' in

https://www.w3schools.com/js/js_ajax_http_send.asp

You can then loop the index name ("fname" and "lname") along with a values ("Henry" and "Ford") using a variables to change these values instead of manually entered as used in

xhttp.open("POST", "ajax_test.asp", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("fname=Henry&lname=Ford"); 

Where the url can be like your very previous original post script "/language" if that will work?

I don't remember if the boards forum AJAX example used this way or not?

Share this post


Link to post
Share on other sites

Hi Dsonesuk,

The above mentioned method is not working.I only get whatever data is available in file.Not henry ford.

I forgot to tell i used GET method to get data continuously.

Now am getting the dynamic data, thats fine.

I have a input text box in my HTML page. What ever the dynamic data i receive is it possible to keep it in text box.

 

Please suggest

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...