Post with jquery

Asked

Viewed 55 times

1

My python endpoint is working perfectly, I’ve done tests using Postman.

The problem is when Javascript will call the method

Follow my Javascript code:

$("#Submit").click(function() {
    var info = $('#form-contact').serializeArray()

    var url = "http://0.0.0.0:5000/sendEmail";

      $.post(url,
      {
        name:  info[0].value,
        subject: info[1].value,
        email:  info[2].value,
        text: info[3].value
      });
});

When I run, the following error appears:

POST http://0.0.0.0:5000/sendemail net:ERR_ADDRESS_INVALID

I repeat that by Postman works perfectly with exactly this address

  • So the difference between Postman and js is that the request is being made by the browser. Chrome? Experiment with another to mislead, and check if in the "Network" tab of Veloper tools there is no IP redirection happening or something similar.

  • http://0.0.0.0:5000? this address is invalid

  • is valid yes...

  • You can [Edit] the question and include the route that answers that call?

1 answer

1

127.0.0.1 is the loopback address (also known as localhost).

0.0.0.0 is a non-transferable meta-address used to designate an invalid address. unknown, or destination not applicable (a 'no specific address reserved space').

Based on this information I performed some Local tests on my Django, I know you are using Flask plus the TCP/IP layer is the same.

I ran my local test server on port 8000:

python manage.py runserver 0.0.0.0:8000

I tried to access IP 0.0.0.0 and received the same error you reported:

ERR_ADDRESS_INVALID

By IP 127.0.0.1 everything ran as expected

Try IP 127.0.0.1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.