0

I've been creating a form to submit values using AJAX and PHP. but every time the value sent the return value of AJAX = 0. i figured it out the problem he page was refreshed.

AJAX

var xhttp = new XMLHttpRequest();
xhttp.open(//code to the php);
xhttp.setRequestHeader("content-type", "application/...");
xhttp.open(data);

In this case I dont want to use jQuery. I want to finish this with Javascript or PHP.

Dave
  • 3,073
  • 7
  • 20
  • 33
rafidkarim
  • 35
  • 1
  • 6

1 Answers1

0

If its valid ajax call then page will not refresh. I am suspecting the button type. If type is submit, sometimes it submit the form and refresh the page. Try to use input type to button and then do an ajax call onclick. Or paste the full caode snippet here!

Anurag
  • 16
  • 3