I am working on my simple test page that was full of forms. As one of you posted few days ago I am now using jquery to use ajax and avoid to refresh the page once one of the submit button are pressed. So just following the template I’ve found here: http://jquery.malsup.com/form/
I’ve added to my webpage this piece of code:
<script>
$(document).ready(function() {
// bind 'myForm' and provide a simple callback function
$('#myForm').ajaxForm(function() {
alert("Thank you for your comment!");
});
});
</script>
What I experience is that now the forms work perfectly but the ajax setTimeout function does not work anymore! If I remove the previous code the ajax setTimeout is working again. Have you guys a clue on why it does like that?
<script type="text/javascript">
function myff(abc)
{
var
$http,
$self = arguments.callee;
if (window.XMLHttpRequest) {
$http = new XMLHttpRequest();
} else if (window.ActiveXObject) {
try {
$http = new ActiveXObject('Msxml2.XMLHTTP');
} catch(e) {
$http = new ActiveXObject('Microsoft.XMLHTTP');
}
}
if ($http) {
$http.onreadystatechange = function()
{
if (/4|^complete$/.test($http.readyState)) {
document.getElementById('ReloadThis3').innerHTML = $http.responseText;
setTimeout(function(){$self(abc);}, 1000);
}
};
$http.open('GET', 'loadfunc.php' + '?abc=' + abc);
$http.send(null);
}
}
</script>
new code:
<script>
$(document).ready(function() {
$('#s1hvform1').ajaxForm(function() {
});
sendreq(abc);
});
function sendreq(abc)
{
$.get('loadfu.php?abc='+abc,function(r)
{
$('#ReloadThis2').html(r);
setTimeout(function(){sendreq(abc);},1000); });
}
</script>
<div id="ReloadThis2">Loading data...</div>
setTimeout() is not an ajax function, and it has to be passed a function handle in the form of a string I am fairly certain. Also, why are you not using jquery for this, seeing as you are in the first code block?