i have little question. in html page have text box, can type anything want
. when press enter want go through next url http://127.0.0.1:8000/search/?request=anythingiwant
is there eny methods in html code?? here code
{% extends 'finder/base.html' %} {% block content %} <div class="container"> <div class="image"></div> <h2>super search engine</h2> <p>i'm searching for:</h2> <input type="text" id="inp" onkeypress="return runscript(event)"> </div> <script> function runscript(e) { if (e.keycode == 13) { //var tb = document.getelementbyid("scriptbox"); //eval(tb.value); //return false; alert("kekos"); $.ajax({ method: 'post', url: 'http://127.0.0.1:8000/search/', data: { 'request': document.getelementbyid('inp').value, }, success: function(data){ $scope.key = data['key']; $scope.isauthorized = true; $window.alert('you logged in.'); }, error: function(data){ $window.alert("something wrong."); }, }) } } </script> {% endblock content %}
if want reload new url, assign window.location
instead of sending ajax request.
if (e.keycode == 13) { window.location = "http://127.0.0.1:8000:/search/?" + encodeuricomponent(event.target.value); }