Really awesome, I get an answer!
But I have to use dataType: 'jsonp'. If I use dataType: 'json' the
alert doesn't work.
Oh my god it was so simple and I was thinking about it a million
hours, thank you a lot.
On 3 Feb., 17:25, rnivash <rniv...@gmail.com> wrote:
> Hi mueller,
>
> The response is look like a function call.
>
> /*
> yasearch(
> {
> "q": "uboot",
> "f": ["k"],
> "r": [["uboote"], ["uboot chat"], ["ubootpc spiel"], ["uboot
> simulation"], ["modell uboot"], ["uboot hamburg"], ["uboot museum"],
> ["atom-uboot"], ["uboot ping"], ["rc uboot"]]
> }
> )
>
> */
>
> try this,
>
> function yasearch(a) {
> alert(a.q);
>
> }
>
> $(function() {
> $.ajax({
> type: 'GET',
> url: 'js.html',
> data: "format=json&id=123",
> success: function(data) {
> eval(data);
> },
> dataType: 'json'
> });
> });
>
> On Feb 3, 5:44 pm, weidc <mueller.juli...@googlemail.com> wrote:
>
> > Hello,
>
> > well i got a problem with using JSON.
>
> > My code looks like this:
>
> > $(function()
> > {
>
> > $.ajax({
> > type:'GET',
> > url: url,
> > data:"format=json&id=123",
> > success:function(data) {
> > alert(data); // doesn't work
> > },
> > dataType:'jsonp'
> > });
>
> > });
>
> > The URL is an external one.
> > The answer looks something like this:
>
> > yasearch({"q":"uboot","f":["k"],"r":[["uboote"],["uboot chat"],["uboot
> > pc spiel"],["uboot simulation"],["modell uboot"],["uboot hamburg"],
> > ["uboot museum"],["atom-uboot"],["uboot ping"],["rc uboot"]]})
>
> > I always get this error msg in firebug:
> > yasearch is not defined
>
> > I tried to define it in any way but it doesn't seem to work. I use
> > JSON for the first time now and don't know how to get an useable
> > answer.
>
> > I hope someone can help me.
No comments:
Post a Comment