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
Guest User
Tech Writer
2.1k
470.7k
How to read values in Ajax call and change status?
Nov 6 2019 7:11 AM
Hi Team
I have two buttons in my HTML, one accept value as being 0 and other one as being 1. Now i want to read these values in Ajax call request. When these are changed, it must show status message to a user the value has been changed from 0 to 1 or vice versa. Currenly my channels are only accepting either one fire first and can view these status on my dashboard channel in thingspeak. Here is the code both HTML and Javascript.
<!-----HTML Buttons------>
<div
class
=
"col-md-2 text-center"
>
<button id=
"singlebutton"
name=
"singlebutton"
class
=
"btn btn-primary"
>Subscribe</button> <br>
</div>
<!------
---->
<br/>
<div
class
=
"col-md-2 text-center"
>
<button id =
"singlebtn"
name=
"singlebtn"
class
=
"btn btn-primary"
>Unsubscribe</button> <br>
</div>
<!----Jquery Buttons------>
<script src =
"https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"
></script>
<script>
$(document).ready(
function
(){
$.ajax({
url:
'https://api.thingspeak.com/update?api_key=D***&field8=0'
,
type:
'GET'
,
data:{
format:
'text'
},
success:
function
(response){
alert(response);
},
error:
function
() {
$(
'#error'
).text(
"There was an error processing your request.Please try again"
);
$(
'#singlebutton'
).append(data);
}
});
// second button for unsubscribe.
$(document).ready(
function
(){
$.ajax({
url:
'https://api.thingspeak.com/update?api_key=D***&field8=1'
,
type:
'GET'
,
data:{
format:
'text'
},
success:
function
(response){
alert(response);
},
error:
function
(){
$(
'#error'
).text(
"There was an error processing your request.Please try again"
);
$(
'#singlebtn'
).append(data);
}
});
});
});
</script>
Reply
Answers (
25
)
Not Get Media url .
Not run code api code