T
T
tincap2015-08-28 15:15:15
Yii
tincap, 2015-08-28 15:15:15

How to get JSON data from a string?

In the controller, I return the response in the form of JSON.
If you look at the response using AJAX, then the response returns an object. Everything is great.

$.ajax({
   url: // ссылка на контроллер
   type: "GET",
   success: function(data) {
     // Здесь data - это объект. Jquery сам спарсил мне Json
   }
});

If you wait for a response from \troy\ImageUpload\ImageUpload, then the answer is already read as a string
'onComplete' => new JsExpression("
  function(fileName, responseJSON) {
    alert(responseJSON); // Здесь не объект, а строка. Причем строка такая <pre>{JSON:JSON}</pre>
  }

What is the right way to get data from a string like {'responce':'ok'} now? Or is there some other way to get the response as JSON?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lander, 2015-08-28
@usdglander

Have you read this?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question