Sunday, January 22, 2012

the POST fix

It seems that one potential solution for the problem described here is to make the AJAX call use POST instead of GET. I'm not sure if it will work or not. I am having trouble reproducing the environment my friend has. I can't get IE to fail in Cassini and in IIS environments IIS itself seems to have a problem with the length of the call before IE specifically does. Maybe my theory is wrong. Code for a potential fix:

<form id="SubmissionFacilitator" method="POST"

      action="/home/successfulsubmission/">

   <textarea name="BlobOfCopy"></textarea>

   <div id="ErrorHint" style="color: #CC0000;"></div>

   <input type="submit" value="submit"/>

</form>

<script type="text/javascript">

   $(function () {

      var wrapper = $('#SubmissionFacilitator');

      var textarea = wrapper.find('textarea[name=BlobOfCopy]');

      $(textarea).keyup(function () {

         var junkbool = assesssanityconcerns($.trim(textarea.val()));

      });

      $('#SubmissionFacilitator').submit(function () {

         return assesssanityconcerns($.trim(textarea.val()));

      });

   });

   function assesssanityconcerns(content) {

      var url = "@ViewBag.WhereAmI";

      url = url + "/home/validate?value=" + content;

      url = url + "&isRequired=true";

      url = url + "&maxSize=5000";

      var message = $.ajax({

         type: "POST",

         url: url,

         async: false

      }).responseText;

      if (message == "good") {

         $('#ErrorHint').html("");

         return true;

      } else {

         $('#ErrorHint').html(message);

         return false;

      }

   }

</script>

No comments:

Post a Comment