我在 onmouseover 函数上发送一个 ajax 请求。这是我的代码
<div id="notifications" class="design" onmouseover="show_drop_downn()" onmouseout="hide_drop_downn()">
<button id="notify"></button>
<?php
if($count_notify>0)
{ ?>
<span id="alert" > <?php echo $count_notify; ?> </span>
<div id="drop_downn" onmouseover="show_drop_downn()" onmouseout="hide_drop_downn()">
<?php foreach($values as $row): ?>
<div id="request_display">
<span id="full_name">
<?php
echo $row->fname;
echo " ";
echo $row->lname;
if($row->status=='1')
{
echo " has accepted your friend request";
}
elseif($row->status=='2')
{
echo " has declined your friend request";
}
?>
<br>
<div id="image_short_fake">
<img id ="img_s" src="<?php echo $this->config->item('base_url'); ?><?php echo '/application/css/'. $row->filename?>"/>
</div>
</span>
<!-- <button id="accept" onclick='setSelected_accept(this)' type="submit" value="<?php echo $row->userid; ?>">Accept</button>
<?php ?>
<button id="decline" onclick='setSelected_decline(this)' type="submit" value="<?php echo $row->userid; ?>">Decline</button>
-->
</div>
<?php endforeach; ?>
</div>
这是我的 show_drop_downn() 函数
function show_drop_downn()
{
document.getElementById("drop_downn").style.visibility = "visible";
$.ajax
({
type: "POST",
url: "http://localhost/ok/index.php/search/ajax_delete_ntify",
success: function(){ alert('ok'); },
error:function(x,e)
{
if(x.status==0){
alert('You are offline!!\n Please Check Your Network.');
}else if(x.status==404){
alert('Requested URL not found.');
}else if(x.status==500){
alert('Internel Server Error.');
}else if(e=='parsererror'){
alert('Error.\nParsing JSON Request failed.');
}else if(e=='timeout'){
alert('Request Time out.');
}else {
alert('Unknow Error.\n'+x.responseText);
}
}
});
}
我已经检查了我的show_drop_downn()
函数被调用的警报。但是ajax方法没有调用http://localhost/ok/index.php/search/ajax_delete_ntify
我已经通过回声确认了这一点。但是,当我在浏览器中编写函数地址时,它会调用该函数。我不知道我的代码有什么问题。请帮我。如果有任何不清楚的地方,请告诉我您还需要什么信息。再次:我的问题是 AJAX 请求不起作用。