Getting "A system error has occurred (more information)" in preSubmit event

Getting "A system error has occurred (more information)" in preSubmit event

e8416o8e8416o8 Posts: 25Questions: 9Answers: 1

I am getting this error even though I see the JSON that is returned from the server in Reponse tab in the Ajax view as follows:
The format complies with one in the tech note found in https://editor.datatables.net/manual/server#Edit.
(I am afraid that I can't provide the link yet.)

Any suggestions?

{
  "data": [
    {
      "insCo": "A",
      "eff": "2014-10-24",
      "insType": "B",
      "groupID": "",
      "payerID": "C",
      "payerName": "D",
      "term": "2078-12-31",
      "rateSchedule": "E",
      "DT_RowId": "123456"
    }
  ]
}

The code snippet for preSubmit is as follows:

    editor.on( 'preSubmit', function ( e, data, action ) {
      var request = new XMLHttpRequest();
      if (action == "create") {
          // do somthing
      }
      else if (action == "edit") {
          alert ("preSubmit---edit");

              payerID = editor.get( 'payerID' );
          payerName = editor.get( 'payerName');
          rateSchedule = editor.get( 'rateSchedule' );
          insCo = editor.get( 'insCo');
          insType = editor.get( 'insType' );
          groupID = editor.get( 'groupID');
          eff = editor.get( 'eff' );
          term = editor.get( 'term');
               
          console.log(JSON.stringify(data));  // Display data

          var jsonOb = JSON.stringify(data);
          request.open("POST", "/myPayers/UpdateData", true);
          
          request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
          request.send('json='+encodeURIComponent(jsonOb));
          
      }

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    If you are getting that specific error message it means that the response from the server is not valid JSON. There must be something other than your JSON data that is being returned from the server. It is possible this could be the invisible BOM characters for UTF8 if there are present in your source files, but more likely there is a warning message or some other data that is making it not valid. Without a link, I'm afraid I can't say for certain what it is.

    Allan

  • pooja@webflight.nlpooja@webflight.nl Posts: 1Questions: 0Answers: 0

    I am having the same problem. the data returned is :

    {
        "data": [{
            "id": "454",
            "name": "My Shop",
            "permaLink": "myshop"
        }]
    }
    

    The ajax request does update the data in the database. It just throws this error. Any help will be appreciated.

    Thanks.

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    What version of jQuery are you using? Editor 1.6.0 has an issue with anything older than 1.12.0. I'm going to release a fix for that tomorrow.

    Allan

  • amanaV36amanaV36 Posts: 20Questions: 9Answers: 0

    Hi there,

    im also getting showed this error. Using jQuery 1.12.3. Aside from getting shown this error there is no effect. Everything works. Could you tell me the class to hide this error message? It is shown to short to inspect.

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    The error you are seeing will occur if the server returns anything other than valid JSON to the Ajax request that Editor sends. The question therefore is, what is the server returning instead of valid JSON? Very often there will be an error message stating the error.

    The information in the tech note explains how you can look at what the server is returning in the browser.

    Regards,
    Allan

This discussion has been closed.