2
Answers

How to fix this error?

Guest User

Guest User

5y
510
1
Hi Team
 
I am struggling to fix this error, can you mates help me on this issue below.
 
 
<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>
 
$(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:{
format:'text',
device_id:'mkr1300',
payload_raw:'AAA'
},
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:{
format:'text',
device_id:'mkr1300',
payload_raw:'AAE'
},
success:function(response) {
alert(response);
},
error:function() {
$('#error').text("There was an error while processing your request.Please try again");
}
});
}
});
});
 
Answers (2)
1
Ashutosh Gupta

Ashutosh Gupta

402 3.9k 1.1m 5y
find command line to open crome with disable functionality of CROS, you can test your functionality using this crome.
 
For Windows go into the command prompt and go into the folder where Chrome.exe is and type
 
chrome.exe --disable-web-security
0
Salman Beg

Salman Beg

155 12.1k 621.2k 5y
Hi.
This is a CORS issue.Follow this link to resolve,
 
https://zinoui.com/blog/cross-domain-ajax-request
 
http://www.ajax-cross-origin.com/how.html
 
https://techblog.constantcontact.com/software-development/using-cors-for-cross-domain-ajax-requests/
 
Thanks.