Solved

ExtJS, issues with trying to create a datastore

Posted on 2010-11-08
2
692 Views
Last Modified: 2012-05-10
I have the following code and it's always failing. What is the best way to provide a detailed error message so I can see what the issue is?
function createDataStore(){

    var url = GLOBAL_URI + '/Users';
    myNamespace.UserDataStore = new Ext.data.JsonStore({
        url: url,
        root: 'Subscriptions',
        id: 'userId',
        fields: [{
            name: 'userId'
        }, {
            name: 'userName'
        }]
    });
    
    var objUser = {
        "userId": "",
        "Id": ""
    };
    
    
    myNamespace.UserDataStore.proxy.conn.jsonData = objUser;
    myNamespace.UserDataStore.proxy.conn.method = 'POST';
    
    myNamespace.UserDataStore.load({
        callback: function(records, o, s){
            if (!s) 
                Ext.MessageBox.show({
                    title: 'Error',
                    msg: 'POST method failed',
                    buttons: Ext.MessageBox.OK,
                    icon: Ext.MessageBox.ERROR
                });
            else 
                Ext.getCmp('ddlUserId').setValue(userId);
        }
    });
}

Open in new window

0
Comment
Question by:PixelMuse
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

by:PixelMuse
ID: 34087961
I've debugged it using Fiddler and it is showing me a "HTTP/1.1 400 Bad Request" error.

Any thoughts on ways to solve that?
0
 
LVL 6

Accepted Solution

by:
youssefomar earned 500 total points
ID: 34092109
I think the error is caused by not specifying the target server side script where the data is supposed to be POSTed

try to add something like this:

myNamespace.UserDataStore.proxy.conn.url = 'file_name.php'

before or after :

    myNamespace.UserDataStore.proxy.conn.jsonData = objUser;
    myNamespace.UserDataStore.proxy.conn.method = 'POST';

0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

689 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question