2012-05-13 8 views
1

検索サーバー(Solr)から取得しているデータをJSONストアに読み込もうとしています。 Firebugでは、私は応答を見ることができます(Solrはデータを返します)が、着信データがロードされるストアを取得できません。JSONP Extjs4の問題

私はローカル(solrのアドレス:localhost:8080/blah/blahと私のアプリケーションのアドレス:localhost:8500/blah/blah)で作業していることに注意してください。

マイ店舗コード:

Ext.define('Ledger.store.Searchstore', { 
    extend: 'Ext.data.Store', 

    requires: ['Ledger.model.Searchmodel'], 

    model: 'Ledger.model.Searchmodel', 

    fields: [ 
     {name:'id', mapping:'id'}, 
     {name: 'model', mapping: 'title'}, 
     {name: 'firstname', mapping: 'firstname'}, 
     {name: 'lastname', mapping: 'lastname'}, 
     {name: 'title', mapping: 'title'}, 
     {name: 'biog', mapping: 'biog'} 
     ], 

    autoLoad: true, 

    proxy: { 
     type:'jsonp', 
     url: 'http://127.0.0.1:8080/solr/select/?q=*:*&fq=model:book&wt=json', 
     //noCache: false, 
     //actionMethods:{create: "POST", read: "POST", update: "POST", destroy: "POST"}, 
     //callbackKey: 'myCallback', 
     reader:{ 
      type: 'json', 
      root: 'response.docs' 
     } 
    } 

}); 

マイモデルコード:

Ext.define('Ledger.model.Searchmodel',{ 
    extend:'Ext.data.Model', 

    fields:[ 
     {name:'id', mapping:'id'}, 
     {name: 'model', mapping: 'title'}, 
     {name: 'firstname', mapping: 'firstname'}, 
     {name: 'lastname', mapping: 'lastname'}, 
     {name: 'title', mapping: 'title'}, 
     {name: 'biog', mapping: 'biog'} 
    ] 

}); 

検索サーバからの着信JSON(それが有効である):

どこか
{ 
    "responseHeader":{ 
    "status":0, 
    "QTime":1, 
    "params":{ 
     "indent":"on", 
     "q":"*:*", 
     "wt":"json", 
     "fq":"model:book"}}, 
    "response":{"numFound":8,"start":0,"docs":[ 
     { 
     "id":"1", 
     "last_modified":"2012-05-12 15:33:07.0", 
     "model":"book", 
     "title":"The Art of Fielding: A Novel", 
     "fake_id":"b_1", 
     "biog":"At Westish College, a small school on the shore of Lake Michigan, baseball star Henry Skrimshander seems destined for big league stardom. But when a routine throw goes disastrously off course, the fates of five people are upended.\nHenry's fight against self-doubt threatens to ruin his future. College president Guert Affenlight, a longtime bachelor, has fallen unexpectedly and helplessly in love. Owen Dunne, Henry's gay roommate and teammate, becomes caught up in a dangerous affair. Mike Schwartz, the Harpooners' team captain and Henry's best friend, realizes he has guided Henry's career at the expense of his own. And Pella Affenlight, Guert's daughter, returns to Westish after escaping an ill-fated marriage, determined to start a new life.\nAs the season counts down to its climactic final game, these five are forced to confront their deepest hopes, anxieties, and secrets. In the process they forge new bonds, and help one another find their true paths. Written with boundless intelligence and filled with the tenderness of youth, The Art of Fielding is an expansive, warmhearted novel about ambition and its limits, about family and friendship and love, and about commitment--to oneself and to others.\t\t\t\t\t"}, 
     { 
     "id":"2", 
     "last_modified":"2012-05-12 15:33:55.0", 
     "model":"book", 
     "title":"The Tiger's Wife", 
     "fake_id":"b_2", 
     "biog":"Starred Review. The sometimes crushing power of myth, story, and memory is explored in the brilliant debut of Obreht, the youngest of the New Yorker's 20-under-40. Natalia Stefanovi, a doctor living (and, in between suspensions, practicing) in an unnamed country that's a ringer for Obreht's native Croatia, crosses the border in search of answers about the death of her beloved grandfather, who raised her on tales from the village he grew up in, and where, following German bombardment in 1941, a tiger escaped from the zoo in a nearby city and befriended a mysterious deaf-mute woman. The evolving story of the tiger's wife, as the deaf-mute becomes known, forms one of three strands that sustain the novel, the other two being Natalia's efforts to care for orphans and a wayward family who, to lift a curse, are searching for the bones of a long-dead relative; and several of her grandfather's stories about Gavran Gailé, the deathless man, whose appearances coincide with catastrophe and who may hold the key to all the stories that ensnare Natalia. Obreht is an expert at depicting history through aftermath, people through the love they inspire, and place through the stories that endure; the reflected world she creates is both immediately recognizable and a legend in its own right. Obreht is talented far beyond her years, and her unsentimental faith in language, dream, and memory is a pleasure."}, 
     { 
     "id":"3", 
     "last_modified":"2012-05-12 15:34:00.0", 
     "model":"book", 
     "title":"State of Wonder", 
     "fake_id":"b_3", 
     "biog":"In State of Wonder, pharmaceutical researcher Dr. Marina Singh sets off into the Amazon jungle to find the remains and effects of a colleague who recently died under somewhat mysterious circumstances. But first she must locate Dr. Anneck Swenson, a renowned gynecologist who has spent years looking at the reproductive habits of a local tribe where women can conceive well into their middle ages and beyond. Eccentric and notoriously tough, Swenson is paid to find the key to this longstanding childbearing ability by the same company for which Dr. Singh works. Yet that isn’t their only connection: both have an overlapping professional past that Dr. Singh has long tried to forget. In finding her former mentor, Dr. Singh must face her own disappointments and regrets, along with the jungle’s unforgiving humidity and insects, making State of Wonder a multi-layered atmospheric novel that is hard to put down. Indeed, Patchett solidifies her well-deserved place as one of today’s master storytellers. Emotional, vivid, and a work of literature that will surely resonate with readers in the weeks and months to come, State of Wonder truly is a thing of beauty and mystery, much like the Amazon jungle itself."}, 
     { 
     "id":"4", 
     "last_modified":"2012-05-12 15:34:05.0", 
     "model":"book", 
     "title":"The Marriage Plot", 
     "fake_id":"b_4", 
     "biog":"A stunning novel—erudite, compassionate and penetrating in its analysis of love relationships. Eugenides focuses primarily on three characters, who all graduate from Brown in 1982. One of the pieces of this triangle is Madeleine Hanna, who finds herself somewhat embarrassed to have emerged from a “normal” household in New Jersey (though we later find out the normality of her upbringing is only relative). She becomes enamored with Leonard, a brilliant but moody student, in their Semiotics course, one of the texts being, ironically, Roland Barthes’ A Lover’s Discourse, which Madeleine finds disturbingly problematic in helping her figure out her own love relationship. We discover that Leonard had been diagnosed with bipolar disorder during his first year at Brown, and his struggle with mood swings throughout the novel is both titanic and tender. The third major player is Mitchell, a Religious Studies major who is also attracted to Madeleine but whose reticence she finds both disturbing and incomprehensible. On graduation day, Leonard has a breakdown and is hospitalized in a mental-health ward, and Madeleine shows her commitment by skipping the festivities and seeking him out. After graduation, Leonard and Madeleine live together when Leonard gets an internship at a biology lab on Cape Cod, and the spring after graduation they marry, when Leonard is able to get his mood swings under temporary control. Meanwhile Mitchell, who takes his major seriously, travels to India seeking a path—and briefly finds one when he volunteers to work with the dying in Calcutta. But Mitchell’s road to self-discovery eventually returns him to the States—and opens another opportunity for love that complicates Madeleine’s life. "}, 
     { 
     "id":"5", 
     "last_modified":"2012-05-12 15:34:07.0", 
     "model":"book", 
     "title":"Steve Jobs", 
     "fake_id":"b_5", 
     "biog":"Based on more than forty interviews with Jobs conducted over two years—as well as interviews with more than a hundred family members, friends, adversaries, competitors, and colleagues—Walter Isaacson has written a riveting story of the roller-coaster life and searingly intense personality of a creative entrepreneur whose passion for perfection and ferocious drive revolutionized six industries: personal computers, animated movies, music, phones, tablet computing, and digital publishing.\r\nAt a time when America is seeking ways to sustain its innovative edge, and when societies around the world are trying to build digital-age economies, Jobs stands as the ultimate icon of inventiveness and applied imagination. He knew that the best way to create value in the twenty-first century was to connect creativity with technology. He built a company where leaps of the imagination were combined with remarkable feats of engineering.\nAlthough Jobs cooperated with this book, he asked for no control over what was written nor even the right to read it before it was published. He put nothing off-limits. He encouraged the people he knew to speak honestly. And Jobs speaks candidly, sometimes brutally so, about the people he worked with and competed against. His friends, foes, and colleagues provide an unvarnished view of the passions, perfectionism, obsessions, artistry, devilry, and compulsion for control that shaped his approach to business and the innovative products that resulted.\nDriven by demons, Jobs could drive those around him to fury and despair. But his personality and products were interrelated, just as Apple’s hardware and software tended to be, as if part of an integrated system. His tale is instructive and cautionary, filled with lessons about innovation, character, leadership, and values."}, 
     { 
     "id":"6", 
     "last_modified":"2012-05-12 15:34:10.0", 
     "model":"book", 
     "title":"The Mill River Recluse", 
     "fake_id":"b_6", 
     "biog":"Having been loaned a Kindle from a friend, I immediately went in search of books that were inexpensive. I stumbled on The Mill River Recluse and the reviews were what made me really want to read this book. Having never written a review before, when I completed this book I felt I HAD to write a review. I was so wonderfully surprised to the depth of characters, storylines and twists and turns along the way. I stayed up all night just to finish it!! I found myself chuckling at times and caught myself off guard with tears rolling down my face. You became part of Mill River and its community almost from the first page. I really didn't want the story to end.\nIf you have only one chance to read a good Kindle book - this is by far the one! I enjoyed it so much, that when I someday purchase my own Kindle, I will be adding (and most likely reading) this book again....one I DEFINATELY want to add to a 'forever' collection!"}, 
     { 
     "id":"7", 
     "last_modified":"2012-05-12 15:34:13.0", 
     "model":"book", 
     "title":"Chasing Amanda", 
     "fake_id":"b_7", 
     "biog":"In \"Chasing Amanda\" Melissa Foster guides us in helping Molly; wife, mother to a teenage son, search for a missing girl. The young girl has disappeared from their quiet, rural community; a place where things like this simply don't happen. For Molly, it's deja vu. Several years earlier, while living in Philadelphia, she witnessed a similar event. She did nothing at that time, and has been tormented by her inaction ever since.\nMolly's special gift, or curse, is her clairvoyance. She can sometimes 'see' things that others cannot. In Philadelphia, she failed the little girl, whose body was found shortly after. Now, she promised herself that she would not make that mistake again. Molly persists, using her clairvoyance and sheer stubbornness in an effort to find the child. In doing so, Molly exposes her town's shameful secrets, presenting a conclusion to this story, that I never saw coming!\nMelissa Foster's skill with her characters, drew me into the story immediately. The suspense that followed made this book a definite page-turner!"}, 
     { 
     "id":"13", 
     "last_modified":"2012-05-12 16:08:48.0", 
     "model":"book", 
     "title":"Kodokan Judo", 
     "fake_id":"b_13", 
     "biog":"Judo, or the Way of Gentleness, an ideal form of physical exercise and a reliable system, of self-defense, was specially created from traditional Japanese martial arts. This book by the creator of Kodokan judo is uniquely comprehensive and the most authoritative guide to this martial art ever published.\r\nOver a hundred years ago Jigoro Kano mastered swordsmanship and hand-to-hand combat. Failing to discover any underlying principle, he set about designing a new martial art to reflect the concept of maximum efficiency in the use of physical and mental energy. Today, the concepts and techniques of judo taught at the Kodokan are the ones originally devised by their creator and collected together in this book. Covering everything from the fundamental techniques to prearranged formal exercises for both men and women, the book offers detailed explanations of how techniques are combined in two types of practice: randori (free practice) and kata (the practice of forms). In addition to a discussion of traditional methods of resuscitation, the book concludes with a useful appendix of information on the founder and the Kodokan International Judo Center, and a glossary of judo terminology. Fully illustrated throughout, Kodokan Judo will help students and instructors everywhere to discover the principles, techniques, and spirit of this popular martial art."}] 
    }} 

私は順番にボタンを持っていますストアを "console.log"するが、私が呼び出すと(ストア定義でautoload属性をtrueに設定していることに気づく)、それは空である。上記のJSON(JSONファイルでサーバーのレスポンスをコピーする)をAJAXプロキシ経由でロードすると、ストアにデータがロードされます。

何が問題ですか?

答えて

1

このいくつかを試してください。

最初のセットは、ストアに入っていないモデルにプロキシを設定します。私は長い間同じ問題を抱えていました。次に、urアプリケーションをリロードしようとします。

第2セットのルート "docs"を直接設定します。

第3セットa Ledger.store.Searchstore.load();

は、最後に私はこの1つのようにプロキシを使用し、私は、リモートのファイルを読むためにどのように私のPHPファイルに左:私はあなたのアプローチに同意

proxy: { 
type: 'ajax', 
api: { 
    read: 'scripts/receive.php', 
    create: 'scripts/create.php?action=create', 
    update: 'scripts/create.php?action=update', 
    destroy:'scripts/destroy.php?action=destroy' 
}, 
+0

。しかし、私はミックス "jsonp"を入れようとしています。とにかく、私は数時間試してみます。もし私が成功しなければ、私はサーバー側に行くでしょう。 ありがとう – anarchos78