jquery - Flash error from an ajax request in compoundjs -


i trying use flash('error', 'error text') alert webpage error has occurred via ajax request. ajax request hits action database work involved, , error produced.

controller:

load('application');  action('index', function() {     this.title = 'sample page';     render(); });  action('test', function() {     flash('error', 'test error message');     render('index', { title: 'sample page' }); }); 

sample ajax call:

$.ajax({     url: '/test-error',     success: function(response) {         console.log(response);     },     error: function(response) {         console.log(response);     } }); 

routes:

map.get('test', 'test-error#index'); map.get('test-error', 'test-error#test'); 

is possible through ajax call? i've tried using flash, followed render('index') shown above , have tried redirect(path_to.test); no success. send(500, 'error message'); returns error ajax call, which, if necessary, reload page there.

the flash messages made html in layout template (look in generated application_layout). therefore, if use render(), generate html , send client (with error flash in it, if printed out in template).

if want send error message server client, can use send([msgno]).


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -