View Full Version : form.load using the url of different domain server to fetch the data & bind to fields

21 Jun 2012, 2:22 AM
I want to load the form fields using json data. I am using extjs 4.1 for ui and asp.net webapi to fetch the data. My objective is to load the data and bind it to the field dynamically which form.load is used for if the name of field corresponds to the data.fieldnameproperty.

i have taken the below link as reference : http://stackoverflow.com/questions/1351424/ext-js-formpanel-not-populating-fields-with-json-data

It loads the data if the Webapi is on the same project :
--ui folder
-- webapi controller folder

but in my case the data is coming from different domain 2 different project for ui and webapi. My form.load code is as below

url: 'http://localhost/WebApiCore/api/Values/',
method: 'GET',
headers: {'Content-type': 'application/json'},
// params: {
// empId: '111'
// },
success: function (form, action) {
//Ext.Msg.alert("Load success", action.result);
failure: function (form, action) {
//Ext.Msg.alert("Load failed", action.result.errorMessage);

I get the error as "NetworkError: 405 Method Not Allowed - "http://localhost/WebApiCore/api/Values/?_dc=1340261175475" in firebug.

my project is running on "http://localhost:54118/PreHospital.htm"

I am not sure is it the problem of extjs not sending the cross domain request using form.load or the problem with webapi doesn't allow cross domain request.

I am not sure how to set extjs to send the jsonp request using form.load.

any kind of help is appreciated.

21 Jun 2012, 9:32 AM
Simply setup your proxy as type jsonp:


23 Jun 2012, 3:04 AM
I want to load the form and do the binding of field with data which i was doing using form.load by passing a url if it is on the same server works well. But if there is a different server that serves the data. Then i am not sure how to use the Jsonp type proxy in the form.load method or what will be the best practice to load the data from different server and bind to fields automatically. Can you plz explain the steps involved?

23 Jun 2012, 5:29 AM
The process is the same as json, except jsonp requires a callback in the return as shown.
You can specify the callback key if required.

Is this not working for you?


25 Jun 2012, 2:41 AM
Well i am not sure about how to set the jsonp in form.load method.