Am I wrong or you are trying to post a form with an ajax request then redirect the page ? What the point ?
Jul 15, 2015
6
Level 2
Get base url for Javascript code
Hi, this is Js code and work fine:
<script>
$("#form").submit(function (e) {
e.preventDefault();
$.ajax({
type : "POST",
url : "http://dev.admin.com/charpost",
dataType : "JSON",
data : {
'name' : $('input[name=name]').val(),
"_token" : $('input[name=_token]').val()
},
success : function(response) {
$('#my_div').html(response.message);
setTimeout("location.href = 'http://dev.admin.com/characteristics'",3000);
}
});
});
</script>
so,this part is interesting for me :
setTimeout("location.href = 'http://dev.admin.com/characteristics'",3000);
Is there way to use some base url or some shorthand, I think this is ugly in code..
Tnx
Please or to participate in this conversation.