Ajax request problem
Ajax request problem
Dear forumers!
I'd briefly describe what i'd like to do with JQuery: I would like to create a webpage that has a button object. When I press it the javascript should trigger an Ajax request to the server. My problem is that this GET event not executed in all cases. Sometimes my code works very charmly, sometimes no GET http message sent to my apache server. To debug the communication I use rawcap application, and wireshark.
Here is some code snippet:
-This is the definition of my button object in html:
<p><input id="login_btn" type="button" name="login_btn" value="Login!" onclick="myFunction()"/></p>
-This is my javascript that handles the click event of the button:
function myFunction()
{
var jqxhr = $.ajax({url: "table.txt", dataType: "text"}).done(
function(datad) {
var parser=new DOMParser();
var htmlDoc=parser.parseFromString(datad,"text/html");
document.getElementById("input").innerHTML=htmlDoc.getElementById("i").innerHTML;
}
)
.fail(function() {alert("error");})
.always(function() {});
}
I'am beginner in the subject of javascript programming, and I cannot understand how could it happen that my code sometimes works perfectly, sometimes not. I am using Firefox for testing.
Somehow it happens, that when I press the button, the old content of the txt file appears in "input" bracket, but formerly i've updated the requested file, and also confirmed that GET request not occurs.
I hope som expert can help me in this problem.
Thank you in advance!