Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>Sugestie backend</title>
- </head>
- <script src="jquery-3.4.1.js"></script>
- <script type="text/javascript">
- function wyslijAJAX() {
- var parametry = {
- "pole": $('#pole').val(),
- "wartosc": $('#pole').val()
- }
- // Inny sposob
- var parametr = new Object();
- parametr.wartosc = $('#pole').val();
- if(parametry.wartosc) {
- $.ajax({
- url: "SugestiejQuery",
- type: "POST",
- dataType: "json",
- data: JSON.stringify(parametry),
- contentType: "application/json",
- mimeType: "application/json",
- success: function(data) {
- $("#wyniki").html("");
- $.each(data.sugestia, function(index, wynik) {
- $("#wyniki").append('<div class="lista">' + wynik + '</div>');
- });
- },
- error: function(data,status,er) {
- alert("error: " + data +
- " status: " + status +
- " error: " + er);
- }
- })
- }
- }
- </script>
- <body>
- <h4>Wpisz marke samochodow</h4>
- <input id="pole" onkeyup="wyslijAJAX()" />
- <div id="wyniki"></div>
- </body>
- </html>
Add Comment
Please, Sign In to add comment