JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://dev.sencha.com/deploy/ext-4.1.0-gpl/resources/css/ext-all.css">
JavaScript
// We define the request here so we can reuse it
var aRequest = {
url: '/echo/json/',
method: 'POST',
// This is not actualy a part of ExtJS
// It's purly to simulate a server response with jsfiddle
params: {
json: '{"type":512, "name":"Izhaki", "address_id":1}',
delay: 1
},
}
Ext.Ajax.on ( 'requestcomplete', function( aConn, aResponse, aOptions, aeOpts) {
var obj = Ext.decode( aResponse.responseText );
if ( obj.type === 512 )
{
var iPass = prompt( "Please enter admin password:", "" );
// aOptions is really the request object
// so inject the new password
aOptions.params.pass = iPass;
// And given the password is right, the server response will now be 501.
aOptions.params.json = '{"type":501, "name":"Izhaki", "address_id":1}'
Ext.Ajax.request( aOptions );
}
});
// Send the request
Ext.Ajax.request( aRequest );
/*
// A real Ajax request will look like this:
Ext.Ajax.request({
url: '/somepathtoaserverscript',
method: 'POST',
success: function(response, opts) {
// we handle the response per request
var obj = Ext.decode(response.responseText);
if ( obj.type === 512)
{
var iPass = prompt( "Please enter admin password:", "" );
}
},
});
*/