amoffat / bootstrap-application-wizard

MIT License
1.85k stars 388 forks source link

Server response codes to trigger `wizard-error` and `wizard-failure` #57

Open arman-h opened 10 years ago

arman-h commented 10 years ago

Hello all,

What headers or JSON need to be returned by the server to trigger wizard-failure and wizard-error? And what is the difference between failure vs error?

Also, returning 200 response from the server still activates the error card. What kinda of a header or JSON response does the wizard expect for success?

Could you please add this information to the documentation?

srk23 commented 10 years ago

Looking at the jquery ajax documentation, if you specify data-type: json (as bootstrap-wizard.js does) then the server has to return valid JSON for success (this can simply be "{}" if you need no data returned).

For example, I am using a PHP script to process the data sent to the server. I just return the following code:

<?php header('Content-type: application/json'); echo('{}'); ?>

This fires the success function correctly. I can access the posted variables in PHP using $_POST['variable_name']; An alternative would be to modify the js to remove the data-type specification. It would be worth highlighting that the server response needs to be valid JSON for the default submit method in the documentation.