我有两个文件,一个是html5,它有一个脚本,可以从输入加载数据,并使用ajax将其发送到另一个php文件,并在html5页面的div中显示php响应。我正在使用eclipse浏览器,但是当我在chrome控制台中验证我的页面时我遇到了问题,我发现这行中存在问题:
xhr.send( ( s.hasContent && s.data ) || null );
这是我的html文件:
<!DOCTYPE html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="jquery.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script>
(function ($) {
// used to keep a reference to the ajax request object
var searchQuery = false;
var showUser = function (str) {
if (searchQuery != false) // if there is a pending request, cancel it
searchQuery.abort();
var searchTerm = $('#matr').val();
// if (str.trim().length < 1)
if (searchTerm.trim().length < 1 ){
$("#txtHint").html('');
return;
}
// clean up the old accordion
if ($("#accordion").length > 0)
$("#accordion").accordion('destroy');
$("#txtHint").html('searching...');
searchQuery = $.ajax({
'url':'http://IP/filename/accueil.php?q='+searchTerm,
'success':function (response) {
searchQuery = false;
$('#txtHint').html(response);
$('#accordion').accordion();
},
'error': function () {
searchQuery = false;
$('#txtHint').html('Sorry, there was an error');
}
});
};
// add the change event to the text field, once the page loads
$(document).ready(function () {
$('#matr').change(showUser);
});
})(jQuery);
</script>
</head>
<body>
<center>
<form name="data" >
<label>Enter the data :</label>
<input type="text" id="matr" >
</form></center>
<br>
<center>
<div id="txtHint"><b>Clique here to show data</b></div></center>
</div>
</body>
</html>
并且php文件只与sql数据库连接,并且:
$q =$_GET['q'];
收集值并将其显示在div中。
但是当我执行时,我得到错误jquery.js文件: xhr.send((s.hasContent&amp;&amp; s.data)|| null);
如果您有任何想法,请