Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

StackOverflow Point

StackOverflow Point Navigation

  • Web Stories
  • Badges
  • Tags
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Web Stories
  • Badges
  • Tags
Home/ Questions/Q 186251
Alex Hales
  • 0
Alex HalesTeacher
Asked: June 10, 20222022-06-10T20:05:18+00:00 2022-06-10T20:05:18+00:00

c# – jquery ajax post error 500 xhr.send((s.hasContent && s.data) || null);

  • 0

[ad_1]

I’m trying to submit with a POST request some data inserted in a text editor, that can contain images in base64 format, pasted by the user. I pass a JSON object with tyhe text in one of the properties, but, when the text contains base64 images, I often obtain an error 500 when the request is sent in this line in jquery.js xhr.send((s.hasContent && s.data) || null);
This error seems to be random, sometimes with same data is not shown and the data is saved, other times the error occurs.
This is the line where I collect the data and call the function that calls the web method to save

function SaveKb() {
  showWaiting();
  var saveUrl = "KnowledgeBase.aspx/SaveKb";
  var keywords="";

  keywords = $('#myTags span.tagit-label').map(function () {
    return $(this).text();
  }).get().join('; ');

  var codesiteid = $('#site').val();
  var chatWorkGroup;

  var data = {
    kb: {
        CODE_HELPSIPUBLICKBID: $('#kbid').val(),
        CODE_SITEID: $('#site').val(),
        CODE_LANGUAGEID: $('#language').val(),
        CODE: ($('#thirdlevelcategory').val() != null ? $('#thirdlevelcategory').val() : -1),
        FLAG_PUBLISHED: $('#published').prop('checked'),
        CODE_HELPSIPUBLICKBCATEGORYID: ($('#thirdlevelcategory').val() != null ? $('#thirdlevelcategory').val() : -1),
        FLAG_ISCHATLINK: $('#chat').prop('checked'),
        DESC_workgroupJID: $('#chatWorkgroup').val(),
        CODE_CONTACTFORMID: $('#contactform').val(),
        FLAG_AVAILABLEFORAGENT: $('#foragent').prop('checked'),
        FLAG_AVAILABLEFORWEB: $('#forweb').prop('checked'),
        DESC_ARTICLETITLE: escapeHtml($('#title').val()),
        DESC_ARTICLENUMBER: $('#articlenumber').val(),
        DESC_ARTICLEQUESTION: CKEDITOR.instances.DESC_ARTICLEQUESTION.getData(),
        DESC_ARTICLEANSWER: CKEDITOR.instances.DESC_ARTICLEANSWER.getData(),
        DESC_ARTICLEANSWER_TYPE: 'html',
        DESC_KEYWORDS: keywords,
        Generazioneautomaticakeywords: $('#generazioneautomaticakeyword').prop('checked')
    }
  };

  data.kb.DATE_TIMECREATED = mUTC2Loc();
  data.kb.DATE_TIMEUPDATED = mUTC2Loc();

  if ($('#kbid').val() == -1) {
    data.kb.CODE_CREATEDBYUSERID = $('#hfCODE_USERID').val();
  } else {
    data.kb.CODE_UPDATEDBYUSERID = $('#hfCODE_USERID').val();
  }

  postData(false, saveUrl, data, onSaveKbCompleted, onSaveKbError);
}

function postData(isAsync, jUrl, data, onSuccess, onError) {
  var params = {
    type: 'POST',
    url: jUrl,
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    async: isAsync,
    success: onSuccess,
    error: onError
  };

  if (data != '') {
    params.data = JSON.stringify(data);
  }

  $.ajax(params);
}

I thought it is because the data size was bigger than the maxJsonLength property in Web.config, but my data length is lower than the maxJsonLength. Further, with the same data sometimes the error occurs and sometimes not. I can’t figure out why I have this error. Thanks

[ad_2]

  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report
Leave an answer

Leave an answer
Cancel reply

Browse

Sidebar

Ask A Question

Related Questions

  • xcode - Can you build dynamic libraries for iOS and ...

    • 0 Answers
  • bash - How to check if a process id (PID) ...

    • 318 Answers
  • database - Oracle: Changing VARCHAR2 column to CLOB

    • 290 Answers
  • What's the difference between HEAD, working tree and index, in ...

    • 285 Answers
  • Amazon EC2 Free tier - how many instances can I ...

    • 0 Answers

Stats

  • Questions : 43k

Subscribe

Login

Forgot Password?

Footer

Follow

© 2022 Stackoverflow Point. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.