Reputation: 77
I have this json: {message:"a"}
I send the request by ajax and then get the response:
<script>
$(document).ready(function(){
$("#l").click(function(){
$.ajax({
url:"index/judement",
type:"POST",
dataType:"json",
contentType:"application/json;charset=UTF-8",
data:JSON.stringify({
number:$("#number").val(),
password:$("#password").val()
}),
success: function (data) {
alert(JSON.stringify(data));
},
error: function () {
alert("...");
}
});
});
})
</script>
And then I get this:
but I just want to get a
!! not all the json! how should I do?
Upvotes: 0
Views: 43
Reputation: 7739
try this remove JSON.stringify()
so that you will get value as object not as string
Try this
alert(data.message);
This will only alert a,
if you will use
alert(JSON.stringify(data.message));
it will alert "a"
Upvotes: 1