Trying to call a webhook after user leave input field with jquery/ajax

94 Views Asked by At

So I'm trying to call a webhook to send the value of a zip code to a webhook. I've modified code that I've found and I'm having no luck getting it to work.

<input type="text" class="street-address w-input" maxlength="256" name="Zip-Code-2" data-name="Zip Code 2" placeholder="Zip Code" id="Zip-Code-2" required=""/>
<div id="zipisright">
right
</div>
<div id="zipiswrong">
wrong
</div>

With this jquery

$(document).ready(function(){
        $('#Zip-Code-2').blur(function(){
    var zip_code = $('#Zip-Code-2').val();
       {
          $.ajax({
              url:"https://amosdigital.app.n8n.cloud/webhook-test/91383285-6a98-42cd-b9a2-6c6312f0090c",
              method:"POST",
              data:{new_base:zip_code},
              dataType:"text",
              contentType:false,
              processData:false,
              success:function(data:
              {
                $('#Zip-Code-2').val(data);
              }
           });
       }
    });
 });

nothing is actually happening when I run the code as is. I've tested it just on documentload as well, with no luck. Any help would be great. Here is a jsfiddle https://jsfiddle.net/kmonie360/fumt3xck/11/

0

There are 0 best solutions below