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
469.6k
How to send message back to things network using javascript
Dec 16 2019 2:12 PM
Hi Team
Is there someone who have once worked with things network to send data, using jquery as a restful client to the broswer or device. I have code that tries to do such logic, but i am seem to be failing to this right. I am not getting help either from stackoverflow. Please help me mates below is my logic.
<div
class
=
"wrapper"
align =
"center"
>
<div
class
=
"btn-group"
id=
"toggle_event_editing"
>
<button type=
"button"
class
=
"btn btn-danger locked_active"
>OFF</button>
<button type=
"button"
class
=
"btn btn-success unlocked_inactive"
>ON</button>
</div>
<div
class
=
"alert alert-danger"
id=
"switch_status"
>Switched off.</div> </div> <br/>
// button for switch functionality on/off.
$(document).ready(
function
()
{
$(
'#toggle_event_editing button'
).click(
function
(){
if
($(
this
).hasClass(
'locked_active'
)) {
$(
'#switch_status'
).html(
'Switched off'
);
$.ajax({
url:
'https://integrations.thethingsnetwork.org/ttn-eu/api/v2/down/acts083_test/mkr1300?key=ttn-account-v2.7Ph6lBffU7wI9cLY5ljIhIb_I7sqH5EVvo5zs9uVyA0'
,
type:
'POST'
,
data:{
payload_raw:
'AAA'
,
dev_id:
'mkr1300'
},
success:
function
(response){
alert(response);
},
error:
function
() {
$(
'#error'
).text(
"There was an error while processing your request. Please try again"
);
}
});
}
else
{
$(
'#switch_status'
).html(
'Switched on.'
);
$.ajax({
url:
'https://integrations.thethingsnetwork.org/ttn-eu/api/v2/down/acts083_test/mkr1300?key=ttn-account-v2.7Ph6lBffU7wI9cLY5ljIhIb_I7sqH5EVvo5zs9uVyA0'
,
type:
'POST'
,
data:{
payload_raw:
'AAE'
,
dev_id:
'mkr1300'
},
success:
function
(response) {
alert(response);
},
error:
function
() {
$(
'#error'
).text(
"There was an error while processing your request.Please try again"
);
}
});
}
});
});
Reply
Answers (
2
)
how to use http integration on your app using jquery ?
how to add a voice search bar in my xamarin application ?