开发者

Sending a json object from extjs page to backend

开发者 https://www.devze.com 2023-04-03 20:48 出处:网络
I am new 开发者_运维问答to Extjs. I wanted to know how can I send a json object to the backend from an extjs page. I am using python to connect to the databse. What I wanted to do was, if an user ente

I am new 开发者_运维问答to Extjs. I wanted to know how can I send a json object to the backend from an extjs page. I am using python to connect to the databse. What I wanted to do was, if an user enters data on the form, that data to be transfered to the database. I am not getting any good tutorials online. Can someone please help??

Thanks in advance.


There are two ways to send Json Object from a form to the Server side for processing and saving in database.

1st way:

Ext.Ajax.request({
  url : 'your-server-url-to-post-to',
  method : 'POST', //or GET, PUT, DELETE.. case sensitive
  jsonData : your-json-object
  params : {
   //your-request-parameters
  },
  success : function(response){ //callback function },
  failure : function(response) { //callback failure function}
});

For direct form submission:

Ext.form.action.submit({
form : your-form-instance,
method : 'POST',
url : 'url-to-post-to',
params : {
//your request params
}
});

or another way of doing it is :

your-form.submit({
//same config options as above, except form : your-form-instance
});

Read the docs for more config options to suit your needs.. Documentation is pretty good. For learning a good coding style for ext js check out the examples that are part of the download package.

0

精彩评论

暂无评论...
验证码 换一张
取 消