本文介绍了JsonP scriptTag extjs4.1问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了以下服务器响应:

this:

var baseUrl = 'http://localhost:8090/';

Ext.define('Ktimatologio.store.NewSingleBlockStore', {
    extend: 'Ext.data.Store',
    alias: 'widget.newsingleblockstore',

    requires: ['Ktimatologio.model.NewSingleBlockModel'],

    model: 'Ktimatologio.model.NewSingleBlockModel',

    groupField: 'search_tag',

    fields: [
        {name:'id', mapping:'id'},
        {name:'id1', mapping:'id1'},
        {name: 'text', mapping: 'text'},
        {name: 'title', mapping: 'title'},
        {name: 'fek', mapping: 'fek'},
        {name: 'date', mapping: 'date'},
        {name: 'descr', mapping: 'description'},
        {name: 'model', mapping: 'model'},
        {name: 'body', mapping: 'body'},
        {name: 'type', mapping: 'type'},
        {name: 'history', mapping: 'history'},
        {name: 'src', mapping: 'url'},
        {name: 'search_tag', mapping: 'search_tag'},
        {name: 'new_element', mapping: 'new_element'},
        {name: 'new_table', mapping: 'new_table'}
        ],

    autoLoad: true,

    proxy: {
        //type:'ajax',
        type:'jsonp',
        url: baseUrl + 'openbd/ktimatologio-final/resources/cfScripts/nea_stoixeia/GetNews.cfc?',
        callbackKey: 'callback',
        extraParams: {
            method: 'jsonP'
            },
        reader:{
            type: 'json',
            root: 'data'
        }
    }

});

我在firebug中看到的网址

Firebug错误:ReferenceError:callback is not defined

Firebug gives me error: "ReferenceError: callback is not defined"

我的问题是:

Ext.data.JsonP.callback2从哪里出现在URL中?

From where does Ext.data.JsonP.callback2 pops up in the url?

我在这里丢失了什么?如何在Extjs4.1中的jsonP工作原理?

What am i missing here? How jsonP in Extjs4.1 works?

我真的需要帮助。

汤姆

希腊

推荐答案

您在响应中使用错误的函数名称。如果你查看请求url,你可以看到它发送在函数名称,你的响应需要调用,你需要使用它在响应数据:& callback = Ext.data.JsonP.callback2,所以响应应该调用函数Ext.data.JsonP.callback2而不是纯回调函数。所以在你的例子的情况下,服务器应该返回这个而不是响应:

You are using the wrong function name in the response. If you look at the request url, you can see that it is sending in the function name that your response needs to call, and you need to use it in the response data: &callback=Ext.data.JsonP.callback2, so the response should call the function Ext.data.JsonP.callback2 instead of just plain callback. So in the case of your example, the server should be returning this instead as the response:

Ext.data.JsonP.callback2({ "data": [ { "id": "13_gnomodotiseis", "id1": 13, "title": "5/2009 ΓΝΜΔ ΕΙΣΑΠ 2009", "text": "5/2009 ΓΝΜΔ ΕΙΣΑΠ ", "model": "gnomodotiseis", "body": "σίλει...", "type": "text", "history": "old", "url": "", "search_tag": "Γνωμοδοτήσεις", "new_element": "true" } ], "dataset": 1 })

这是因为callback = Ext。 data.JsonP.callback2已在请求中发送。

This is because callback=Ext.data.JsonP.callback2 was sent in the request.

这篇关于JsonP scriptTag extjs4.1问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 04:11