JSFiddle - React, Tailwind, and code Playground
by Kajus
HTML
<input type="text" id="eingabewert" value="" placeholder="klick hier enter" autofocus>
JavaScript
$('#eingabewert').keydown( function(e)
{
if(e.keyCode == 13)
{
alert('Enter-Taste gedrückt');
do_ajax_call();
}
});
// deine Funktion für den Ajax call
function do_ajax_call()
{
var inputvalue = $('#eingabewert').val();
var extradata = "Whatsoever, your choice";
$.ajax({
url: '/ziel', // modifizieren
type: 'post',
data: { value_in: inputvalue, someid: extradata },
success: function(data)
{
console.log(cookiedata);
if(data=='success')
{
// do your stuff
}
},
error:function()
{
console.log('server problem');
}
});
};