I have a page with 3 input fields. Pressing the submit button is supposed to submit the contents of those fields to a database, where it will be added, after checking that the password matches. Javascript as follows:
var ajReq = new XMLHttpRequest();
$(document).ready(function () {
$('#btnRegister').on('click', function () {
if ($('#pass1').val() != $('#pass2').val()) {
alert('confirm your password');
return false;
} else {
$.ajax({
type: "POST",
url: "../Services/Page.asmx/Add",
data: JSON.stringify({ name: $('#name').val(), secondname: $('#secondname').val(), Password: $('#pass1').val() }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert("Added");
}
});
}
});
});
[WebMethod]
public void Add(string name, string secondname, string password)
{
try
{
util.Add(name, secondname, password);
}
catch ()
{
}
}
I'm finding, though, that when I run the page and hit submit, nothing happens. Can anyone tell me what I'm doing wrong?
Also, after the url, I have something like ../../service.... - what do those two dots follow by slash and followed by two dots mean?
this is how i am calling name input field:
<input id="name" type="text" class="form-control" required="" />
..references the parent directory of the current page's location.../../references the grand-parent directory, two levels up.