TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Faisal
NA
73
1.6k
Why triggering second event "onmouseup" is getting error !
Aug 9 2019 11:01 PM
When i click on the button it is working, but when i release the button second event "onmouseup" is triggered and ajax function is getting error. Is there anything wrong in the script ?
<
button
id
=
"myP"
onmousedown
=
"mouseDown_b()"
onmouseup
=
"mouseUp_b()"
>
Click Me
</
button
>
<script>
function
mouseDown_b() {
//e.preventDefault();
document.getElementById(
"myP"
).style.color =
"red"
;
$.ajax({
type:
"POST"
,
url:
"Default.aspx/testMethod_a"
,
data:
"{ currentState: 1 }"
,
contentType:
"application/json; charset=utf-8"
,
dataType:
"json"
,
//async:false,
success:
function
() {
console.log(
"success1"
);
},
error:
function
() {
alert(
"error"
);
}
});
}
function
mouseUp_b() {
//e.preventDefault();
document.getElementById(
"myP"
).style.color =
"green"
;
$.ajax({
type:
"POST"
,
url:
"Default.aspx/testMethod_a"
,
data:
"{ currentState: 2 }"
,
contentType:
"application/json; charset=utf-8"
,
dataType:
"json"
,
//async:false,
success:
function
() {
console.log(
"success2"
);
},
error:
function
() {
alert(
"2nd_error"
);
}
});
}
</script>
Reply
Answers (
2
)
Image Download with web api and ajax
Ajax and jquery.