I've got a command.cgi that returns a website url, if the checkbox with id="simple" is checked then redirect the user to that page, if not, add the html formatted link to a container. The problem is that it doesn't redirect the user to a html formatted link when the checkbox is checked and when it does, it redirects the user to a formatted html link, it's crazy. Any solution? Thanks
<script type="text/javascript">
$(document).ready(function() {
$("#sudo").click(function(event){
if ($("#simple").attr('checked')==1){
$.get("/cgi-bin/command.cgi",
{ cmd: $("#cmd").val()},
function(data) {
window.location.href=data;
});
}else{
$.get("/cgi-bin/command.cgi",
{ cmd: $("#cmd").val()},
function(data) {
$('#resultado p').prepend("<a href=\"" + data + "\" target=\"_blank\">" + data + "</a><br><br>");
$("#cmd").val('');
$("#cmd").focus();
});
}
});
$("#cmd").keyup(function(e){
if(e.keyCode == 13){
$("#sudo").click();
}
});
});
</script>