I have a java file called myJavaFile.java. Inside this java file, I have the following java code:
private void addUploadscript() {
//my java variable
String fn = session.getUser();
html.addElement("<script language=\"JavaScript\" type=\"text/javascript\">");
html.addElement("function ajax_post(){");
html.addElement("var hr = new XMLHttpRequest();");
html.addElement("var url = \"http://localhost:8080/bunk/inf?cmd=Dialer.opts#\";");
html.addElement("var vars = \"firstname=\"+fn;");
html.addElement("\talert(vars)");
html.addElement("hr.open(\"POST\",url,true);");
html.addElement("hr.setRequestHeader(\"Content-type\",\"application/x-www-form-urlencoded\");");
html.addElement("hr.onreadystatechange = function() {if (hr.readyState == 4 && hr.status == 200) {var return_data = \"my server is reached\";document.getElementById(status).innerHTML = return_data;} } ");
html.addElement("hr.send(vars);");
html.addElement("document.getElementById(status).innerHTML = \"processing....\";");
html.addElement("}");
html.addElement("</SCRIPT>");
}
I already tried to find my response by reading the other topics but I still can not resolve my problem. I actually tried to do it step by step and display my variables to make sure that I wrote everything fine.
Thank you very much for your help!