0

I have request

$.ajax({
url: 'http://translate.google.ru/translate_a/t',
        data: { client: "x", text: sourceText, sl: langFrom, tl: langTo },
        dataType: 'jsonp',
        success: function (data) {
            alert("Success");
        }

In response to this process i have file t.js . The contents of this file is

{
    "sentences":[{
        "trans":"был в школе",
        "orig":"був в школі",
        "translit":"byl v shkole",
        "src_translit":"buv v shkoli"
        }],
    "src":"uk",
    "server_time":40
    }

But in dragonfly i have javascript error

Syntax error at line 1 while loading:
{"sentences":[{"trans":"вход вых
------------^
expected ';', got ':'

I need get trans obj.

3
  • 1
    Why are you using JSONp and not just JSON? JSONp is typically used for cross domain 'requests'. Commented Dec 6, 2011 at 13:03
  • It's the same case. I need cross domain 'requests'. Commented Dec 6, 2011 at 13:15
  • It IS a cross domain request. The url starts with http://translate.google.ru/ Commented Dec 8, 2011 at 12:32

1 Answer 1

1

use $.getJSON() function instead of $.ajax()

Sign up to request clarification or add additional context in comments.

1 Comment

@Sasha : then use JSON.parse() function to convert a string into a JSON format

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.