jquery - How can I I pass "12mca22@nirmauni.ac.in" in ajax data field? -
i trying pass 12mca22@nirmauni.ac.in
in ajax giving me such error
'unexpected token illegal.'
how can pass such string in ajax?
this code
$.ajax({ url:'http://localhost/student', type: 'post', data: { data:"12mca22@nirmauni.ac.in" }, success: function(data) { alert(data); } });
your string fine, jquery's throwing fit because you've got comma. remove it:
data: { data:"12mca22@nirmauni.ac.in" },
and should fine. jquery expects data
field contain json object, comma there makes json syntax invalid , it's unexpected, error message says
the below code executes fine.
$.ajax({ url:'http://httpbin.org/post', type: 'post', data: { data:"12mca22@nirmauni.ac.in" }, success: function(data) { console.log(data); } });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Comments
Post a Comment