Reputation: 257
I have a PHP file particular.php which have menu to serve sub pages. Once I click on a menu it loads page which I asked for without refreshing the main page i.e particular.php. Once the sub-page is loaded I create a SESSION which will store current page.
Following are codes I tried and seems no refreshing menu div.
echo '<footer id="ajaxmenu">';
echo '<ul>'
if ( $_SESSION["ajax_show"] == 'result') {
echo "<li style='text-decoration: underline;'>";
} else {
echo '<li>';
}
echo "<a href='#' onclick=\"result(); return false;\">Academic</a></li>";
echo '</ul>';
echo '</footer>';
}
JQuery ajax.
function result(year) {
var year = year.value;
$.ajax ({
type: "POST",
url: "result.php",
data: { year: year},
success: function(data),
$("#result").html(data);
}
});
$("#ajaxmenu").load("#ajaxmenu");
return false;
}
In Nutsheell, When I click on menu, I want #ajaxmenu to be refresh without loading whole page.
Upvotes: 0
Views: 152
Reputation: 11281
In your AJAX success
replace $("#result").html(data);
with $("#ajaxmenu").html(data)
. As for now it seems like you are loading your data response in the wrong container - nothing of id="response"
in your code.
Also, it might lead to nesting <footer>
tags inside each other, so you should bear that in mind as you prepare the HTML
.
Upvotes: 1