ASP .NET MVC Ajax link that gets executed onmouseover
Date : March 29 2020, 07:55 AM
wish help you to fix your issue Use jQuery to fire the click event of the link $(selector).mouseover(function () {
$(this).click();
});
$(selector).mouseover(function() {
$.ajax({
type: "GET",
url: "/my/path/to/someplace",
complete: UpdateUI});
}).click(function() {
alert("tada");
});
function UpdateUI(XMLHttpRequest, textStatus) {
//Update Your UI
}
|
$.ajax Call Error while my Call get successfully executed
Date : March 29 2020, 07:55 AM
it should still fix some issue After looking at the response and code for more time, i got the problem ,my webmethod response in the json format while i am looking data in xml format,as u can see in above code dataType: "xml" which i change to json and now i am getting it correctly. thanks every one
|
AJAX call not being executed
Date : March 29 2020, 07:55 AM
wish help you to fix your issue Your AJAX request is being cancelled because immediately after the AJAX is initiated, your form does its standard form submission, with the browser reloading the page. You need to either return false or prevent default, in the submit event: $('form').bind('submit',function(){
...
...
return false;
});
$('form').bind('submit',function(e){
e.preventDefault();
...
...
});
|
Popover won't hide after ajax call and not hovering action
Date : March 29 2020, 07:55 AM
hop of those help? Instead of using hover event, you can use mouseenter and mouseleave events. $('[data-toggle="popover"]').on("mouseenter", function() {
var e=$(this);
$.ajax({
url: '/comentario/1',
dataType: 'html',
success: function (data) {
e.popover({content: data}).popover('show');
}
});
});
$('[data-toggle="popover"]').on("mouseleave", function() {
var e=$(this);
$(this).popover('hide');
});
|
JS not executed after AJAX call
Date : September 12 2020, 01:00 PM
it fixes the issue From what I can see, you are calling addEventListener before .cities-select exists (you load the page -> tries to loop over .cities-select but it doesn't exist). You need to add your event listeners in your $.Ajax#success function, after you have set .innerHTML. const search = document.querySelector("#city-search");
const results = document.querySelector(".result");
// works
search.addEventListener("keyup", e =>{
let city = search.value;
if(city != ""){
loadCities(city);
}
});
// works
const loadCities = (city) => {
$.ajax({
url: "config/fetch-cities.php",
method: "GET",
async: true,
data: {
query: city
},
success: function(data){
results.innerHTML = data;
const cities = document.querySelectorAll(".cities-select");
cities.forEach(city => {
city.addEventListener("click", e =>{
console.log("hello world");
})
})
}
});
}
|