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>

enter image description here

jsfiddle

enter image description here


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -