保存并退出以及保存并继续

For a textarea I want to give the user two options for saving.

  1. save the document and continue editing.
  2. save and exit

No I know how to save and continue with a AJAX call. And of course save and exit is easy. The combination of the two is confusing me. I tried some Googling but without any luck. Can someone point me in the right direction?

Thanks!

Edit... My code:

 <script src="https://code.jquery.com/jquery-1.9.1.js"></script>
 <form action="post" action="save.cfm" name="formname" id="formname">
 <textarea name="text"></textarea>
 <input type="submit" value="save and exit">
 <input type="submit" value="save and continue">
 </form>



 <script>
 $(function () {
 $('#formname').on('submit', function (e) {
 $.ajax({
type: 'post',
url: '/wall/save_and_continue.cfm',
data: $('form').serialize(),
success: function () {
  alert('form was submitted');
}
 });
 e.preventDefault();
 });
 });
 </script>

If you know how to do both save and exit as well as save and continue, then just use both options and add a conditional in your code so that it does save and exit when you click that button and it does save and continue when you click that button

EDIT

Try something like this which will give the buttons an ID, then the Jquery will use the separate code depending on whether the user clicks save and exit or save and continue:

<script src="https://code.jquery.com/jquery-1.9.1.js"></script>
<form action="post" action="save.cfm" name="formname" id="formname">
<textarea name="text"></textarea>
<input type="submit" id="save_exit" value="save and exit">
<input type="submit" id="save_cont" value="save and continue">
</form>



<script>
$(function () {
  $('#formname #save_cont').on('submit', function (e) {
    $.ajax({
      type: 'post',
      url: '/wall/save_and_continue.cfm',
      data: $('form').serialize(),
      success: function () {
      alert('form was submitted');
      }
    });
    e.preventDefault();
  });
});

$(function () {
  $('#formname #save_exit').on('submit', function (e) {
    DO Save and Exit Code  
  });
    e.preventDefault();
  });
});

</script>