![](https://csdnimg.cn/release/download_crawler_static/8832311/bg4.jpg)
params: {
username: 'Ed',
password: 'bad place for a password'
},
callback: function (options, success, response) {
console.log(response.responseText);
}
});
Since the request no longer contains the cache busting string, it looks like the following string:
http://mywebsite.com/myUrl?username=Ed&password=bad%20place%20for%20a%20password
Sending Headers
Another option related to(有关) customizing(定制) the request is the headers option. This
enables you to send any custom(自定义) headers to your server, which is often useful when
the web server returns different content based on these headers. For example, if your web
server returns JSON, XML, or CSV based on the header it is passed, we can request JSON
like in the following example:
Ext.Ajax.request({
url: 'myUrl',
headers: {
"Content-Type": "application/json"
},
callback: function (options, success, response) {
console.log(response.responseText);
}
});
If you create a request like this and inspect(检查) it in Firebug/web inspector, you will see that
the Content-Type header has been set to application/json. Your web server can pick up on
this and send you the right response. You can pass any number of headers you like into the
headers option.
Callback Options
Not every AJAX request succeeds: sometimes the server is down, or your internet
connection drops(中断), or something else bad happens. Ext.Ajax allows you to specify(指定)
separate(不同的) callbacks for each of these cases:
Ext.Ajax.request({
url: 'myUrl',
success: function (response) {
console.log("Spiffing, everything worked");
},