title: Invalid JSON Response?
body: <p>I have a page that does some stuff and then outputs a JSON response. This page is called from a jQuery Ajax call but when I inspect the post in Firefox I get Invalid JSON which I do not understand.</p>
  
  <p>Here is the code of the page</p>
  
  <pre><code>Write("{status: 'ERROR', StatusCode: '" + result.StatusCode + "',payload: ''}");
  </code></pre>
  
  <p>The output looks like this (looks right to me?)</p>
  
  <pre><code>{status: 'ERROR', StatusCode: '200',payload: ''}
  </code></pre>
  
  <p>Here is my AJAX Call</p>
  
  <pre><code>$.ajax({
              type:"POST",
              url: copyBUURL,
              data: { action: "copy_bu", bu_id: selected_bu.id, bu_name: selected_bu.name, new_parent: new_parent_bu.id, new_parent_name: new_parent_bu.name, new_name: $("#bu_name").val(), from_name: $("#bu_fromname").val(), email: $("#bu_email").val() },
              contentType:"application/x-www-form-urlencoded; charset=utf-8",
              dataType:"json",
              success:function(data){
                  if(!data)
                  {
                      alert("There was an error processing your request");
                      return false;
                  }
                  $("#createBtn").removeAttr("disabled");
                  $("#cancelBtn").removeAttr("disabled");
  
                  console.log("Data response: " + JSON.stringify(data));
  
                  //xhr_users Landing Page
                  showUrlInDialog('https://pages.umusic-mail.com//page.aspx?QS=472529ec60bdf32a5a46a47dceedf4ab0793800df7757ecbd2298ad0f8bc85eb&amp;bu_id=' + data.bu_id + '&amp;bu_name=' + data.bu_name);
  
                  if (data.status == "OK") {
  
                      $("#msgBox").css("height", "80px");
                      $("#result").html("The Business Unit was successfully copied!&lt;br /&gt;&lt;br /&gt;Users will be assigned very shortly. (You will see a dialog window pop up in this page).");
                      $("#loader").attr("src", "https://dl.dropbox.com/u/417891/aeg-checkmark.png").css("display", "inline");
                      hideContainer();
                      resetForm();
                      $("#business_units").jstree("refresh");
                  } else if (data.status.toUpperCase() == "ERROR") {
                      displayError(data.payload);
                      $("#msgBox").attr("class", "msgBoxOff");
                      $("#result").html("");
                      $("#loader").css("display", "none");
                  } else {
                      // something way wrong
                  }
              },
              error: function (xhr, ajaxOptions, thrownError) {
                  console.log(xhr.status);
                  console.log(thrownError);
              }
          });
  </code></pre>