I am near a solution to get json data, just get the error : SyntaxError: missing ; before statement
My json data look like this :
{"custom1":"","dateOfBirth":null,"custom2":"","custom3":"","custom4":"","custom5":""}
I am using jsonp. this solved my problem with CORS (Cross-origin request blocked) In the debugger i can see the data in the NET. How close i am? Som get me the last push to resolve my problem??
<script type="text/javascript">
function getdata() {
$.ajax({
type: 'GET',
url: 'http://myurl/api/getUser/22?_key=123456789',
dataType: 'jsonp',
//contentType: "application/jsonp",
success: function (data) {
$('#badge').append(result);
}
});
}
You have to set your ajax response type to jsonp
instead of json
.
Like
dataType: 'jsonp'
You can read more about it in jquery docs on $.ajax
. Also as I can see, the result
variable that you are trying to append in the success callback is not declared & inititalized anywhere in the code you have provided.