0

I get this console Error In Code

Uncaught SyntaxError: Unexpected token o in JSON at position 1

This is the ajax request and It shows the respose data on console but cant get in to a variable.

request = '4';
$.ajax({
  url: 'check_details.php',
  type: 'post',
  data: { softwarekey: softwarekey,request: request, },
  dataType: 'json',
  success: function ( upresponse ){
    var result = JSON.parse( upresponse );

    var software_key = result.software_key;
    var total_days_left = result.total_days_left;
  }
});
Phil
  • 157,677
  • 23
  • 242
  • 245
Jyothish V
  • 15
  • 8
  • 2
    You do not need `JSON.parse()`. jQuery has already done that for you because you told it to expect JSON with `dataType: 'json'` – Phil Oct 21 '19 at 10:55
  • Possible duplicate of [I keep getting "Uncaught SyntaxError: Unexpected token o"](https://stackoverflow.com/questions/8081701/i-keep-getting-uncaught-syntaxerror-unexpected-token-o) – Phil Oct 21 '19 at 10:57
  • 1
    @phil solved i just simply used var result = upresponse ; Instead Of var result = JSON.parse( upresponse ); – Jyothish V Oct 21 '19 at 11:04
  • That's great. Happy coding – Phil Oct 21 '19 at 11:05

0 Answers0