How to store Json on host site via Ajax?

Asked

Viewed 59 times

0

<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<title> teste </title>
<body style="background-color: white">

  <form>
  Primeiro Nome: <input class="nome1" type="text" name="FirstName" value=""><br>
  Segundo Nome: <input  class="nome2" type="text" name="LastName" value=""><br>
  <input class="enviar" type="submit" value="Submit">
  </form>

<script>


$(".enviar").click(function(){

  event.preventDefault();

  nome1 = $(".nome1").val();
  nome2 = $(".nome2").val();

  var banco = [
    {
    nome : nome1,
    sobrenome : nome2
  }
]

  console.log(banco);

  $.post("http://localhost:3000/teste", banco, function(){
    console.log("ok");
  });

});

am running server not Response 404 error ( not found )

Can you help me?

  • 3

    And what would be http://localhost:3000/teste? Some page served by Nodejs?

  • You can show the code you have on Node.js to handle that url?

No answers

Browser other questions tagged

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