0

i have the same json string twice but the second time i get an error.

{"data":[{"ServerID":"1","UserID":"3","Name":"salzig","State_since":"2012-11-23T23:16:27.458000000","State":"saved","UUID":"Hardware   85f5d278-f6d6-49c2-87e7-c249d8002897"}],"error":[null,null,null]} devcontrol.js:8

{"data":[{"ServerID":"1","UserID":"3","Name":"salzig","State_since":"2012-11-23T23:16:27.458000000","State":"saved","UUID":"Hardware   85f5d278-f6d6-49c2-87e7-c249d8002897"}],"error":[null,null,null]} devcontrol.js:8

Uncaught TypeError: Object function (E,F)} has no method 'parseJSON' devcontrol.js:9

my code line devcontrol.js 8 and 9:

console.log(data);
data = $.parseJSON(data);

how can that be.

update i now made a console.log($) evry trime bevor he trys to convert the string into a json and got

undefined

it turnd out the secounde time it's undefined. i managed to found out it was because of zfdebug they used document ready and then asked about jquery noconfilect thats why $ was undifend the secound time

10
  • 1
    Are you using any other libraries that use $ as a variable? What happens when you try jQuery.parseJSON(data); Commented Nov 24, 2012 at 2:04
  • show more code where the json comes from. Is data an object or a string? Commented Nov 24, 2012 at 2:06
  • @charlietfl - What's the difference? Commented Nov 24, 2012 at 2:07
  • You're going to need to give more information about what's going on in your code, because obviously there isn't just a bug in jQuery where it can't parse that string twice. Commented Nov 24, 2012 at 2:07
  • @Aesthete read the docs. Description: Takes a well-formed JSON string and returns the resulting JavaScript object. api.jquery.com/jQuery.parseJSON Commented Nov 24, 2012 at 2:09

1 Answer 1

2
Uncaught TypeError: Object function (E,F)} has no method 'parseJSON' devcontrol.js:9

Is telling you that the object you're referencing with the $ variable has no method called that. This could be caused by a few things.

  • You're using an old version that doesn't support this function. parseJSON was introduced in version 1.4.1. Either update your version, or use the native JSON.parse() method.
  • Your script link to jQuery is wrong. Checked the page loaded the source script with a 200 success
  • Another library is taking the $ variable after jquery has defined it. You can disassociate jQuery from the $ variable using jQuery.noConflict(), reassign to anothe variable like $$, or just using jQuery.parseJSON()
  • You have scripts running before the page is fully loaded. Make sure every is run within $(document).ready(function () { /*your code here*/ });
Sign up to request clarification or add additional context in comments.

1 Comment

also make sure jQuery loaded before any jQuery dependent code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.