I am sending an ajax request on onmouseover function. This is my code
<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>
this is my show_drop_downn() function
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!!
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.
Parsing JSON Request failed.');
}else if(e=='timeout'){
alert('Request Time out.');
}else {
alert('Unknow Error.
'+x.responseText);
}
}
});
}
i have already checked through an alert that my show_drop_downn()
function is called. But the ajax method is not calling http://localhost/ok/index.php/search/ajax_delete_ntify
i have confirmed that with an echo. However when i write the function address in browser it calls the function alright. I dont know what is wrong with my code. Please help me. And if anything is not clear please tell me what more information you need. AGAIN: MY PROBLEM IS THAT AJAX REQUEST IS NOT WORKING.
In FIreFox press F12 and a window at bottom of the browser will open. Find the console tab and click it. Then refresh the page and then check the ajax request. Whatever error you got, you will see in the console. You will see the ajax call, and also its response. Copy paste that call and response and then will guide you. Firebug is another tool vastly used in web development and for such issues you have now.
According to your comment JQuery is not included. Please include jquery at top of the page under head section. the $ sign in java script is used in jquery thats why it is giving you erorr of $ is not defined as jquery is not included. Include it as below directly from google
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
or download it from jquery.com
THank you