I have ajax function like this:
$("#noOfFollowing").click(function(){
$.ajax({
url : 'Details',
type : 'POST',
data: "",
success : function(msg) {
$("#NOFOLLOWING").html(msg);
}
});
});
and my html element is
<u id ="noOfFollowing"></u><i id="NOFOLLOWING""></i>
i want to call the ajax function without clicking the html element. It should be called after every page reload. As soon as reload my web page this function should be called immediately without clicking separately. Here the url is a servlet. If some other alternative is there then please suggest them also.
You should put your Ajax call in this:
$(document).ready(function (){
$.ajax({
url : 'Details',
type : 'POST',
data: "",
success : function(msg) {
$("#NOFOLLOWING").html(msg);
}
});
});
Try this way
function get_data(){
$.ajax({
url : 'Details',
type : 'POST',
data: "",
success : function(msg) {
$("#NOFOLLOWING").html(msg);
}
});
}
HTML
<u id ="noOfFollowing" onclick="get_data()" ></u><i id="NOFOLLOWING""></i>
In Script
$(document).ready(function(){
get_data() //After page load this function called
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.