Does anybody have any idea why this doesn't work?
$(document).ready(function() {
var loading;
var results;
form = document.getElementById('form');
loading = document.getElementById('loading');
results = document.getElementById('results');
$('#Submit').click( function() {
if($('#Search').val() == "Desired name here..")
{alert('Please enter a valid domain name, Thank you.');return false;}
results.style.display = 'none';
$('#results').html('');
$("#loading").fadeIn(2000);
$.post('process.php?domain=' + escape($('#Search').val()),{
}, function(response){
results.style.display = 'block';
$('#results').html(unescape(response));
loading.style.disp开发者_如何学Pythonlay = 'none';
});
return false;
});
});
HTML:
<a href="#" id="Submit"><img src="img/submit_domain.png" height="30" width="73" class="host_sb"></a>
I have jQuery installed, and it works in every other browser.
This is my problem:
Nothing loads. The #loading doesn't show which in turn doesn't display the #results
Your code is weird mix of plain JavaScript and jQuery.. not sure this cause the problem but try this optimized version:
$(document).ready(function() {
$('#Submit').click(function() {
var searchValue = $('#Search').val();
if (searchValue === "Desired name here..") {
alert('Please enter a valid domain name, Thank you.');
return false;
}
var oResults = $('#results');
oResults.html('');
oResults.hide();
$("#loading").fadeIn(2000);
var now = new Date();
$.post('process.php?domain=' + encodeURIComponent(searchValue) + '&t=' + now.getTime() , { }, function(response) {
oResults.show();
oResults.html(decodeURIComponent(response));
$("#loading").hide();
});
return false;
});
});
If no luck, try debug if you don't have any tools use plain old alert - add alert('got here');
in key lines like the beginning of the .click()
function or the AJAX callback.
精彩评论