I wanted to send name and password from jsp in the form of json to servlet but this is not working. What might be the problelm?
Here is my snippets.
function submitForm(thisObj, thisEvent) {
var name = $('#name').val();
var password = $('#password').val();
var myData = {
"mydata": {
"name": name,
"password": password
}
};
$.ajax({
type: "GET",
url: "/Aasd",
data: {
jsonData: JSON.stringify(myData)
},
dataType: "json"
});
return false;
}
<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js”>
</script>
<body>
<h2>Login</h2>
<form enctype='application/json'>
Name:<input type="text" value="name" id="name"><br> Password:
<input type="password" id="password"><br>
<input type="submit" name="submit" onclick=" return submitForm(this,event)">
</form>
</body>