Hi,
We need to pass some data in the form of an array to be displayed in a table in enet_io example.
The code:
else if(ustrncmp(pcName, "/cgi-bin/get_result", 10) == 0) { static char pcBuf[6]; // // Get the test result as string......... // io_get_test_result(pcBuf, 6); psFile->data = pcBuf; psFile->len = strlen(pcBuf); psFile->index = psFile->len; psFile->pextension = NULL; UARTprintf(pcBuf); return(psFile); }
The above code sends the data to the browser obtained from this:
void io_get_test_result(char *pcBuf, int iBufLen) { usnprintf(pcBuf, iBufLen, "%d", testresult); }
Now instead of test result we need to send an array testresultarray
int testresultarray[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
What changes are required in the code here? Also what needs to be done at the javascript part which is as below
//Test Result Display TryOuts-------------------------------------------------------// function test() { var req = false; function TestComplete() { if(req.readyState == 4) { if(req.status == 200) { document.getElementById(1).innerHTML = "<div>" + req.responseText + "</div>"; //we will have id = "1", id = "2" etc } } } if(window.XMLHttpRequest) { req = new XMLHttpRequest(); } else if(window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); } if(req) { req.open("GET", "/cgi-bin/get_result?id" + Math.random(), true); req.onreadystatechange = TestComplete; req.send(null); } }
Please provide help.
Thanks
Vikram