Forum Stats

  • 3,782,577 Users
  • 2,254,668 Discussions
  • 7,880,129 Comments

Discussions

Error: SyntaxError: Unexpected end of JSON input

Geert01
Geert01 Member Posts: 141 Bronze Badge

I have a page that uses an Ajax Callback process to execute some plsql code. This works just fine.

But after adding a call to another (database) procedure, I am getting the error Unexpected end of JSON input.

My Ajax Call back process has the following lines (this was necessary to prevent the same Unexpected end of JSON input, error:

  apex_json.open_object;  

  apex_json.write('success', true);  

  apex_json.close_object; 

But the procedure that I added also uses :

  apex_escape.set_html_escaping_mode('B'); 

  apex_json.initialize_clob_output ();

  apex_json.open_object ();

  apex_json.write ('on', p_on);

  apex_json.close_all ();

  l_req_body := apex_json.get_clob_output ();

  apex_json.free_output ();

When I deactivate this block, the error no longer appears. I have tried to solve this problem by making the procedure an autonomous transaction procedure, but that does not solve it.

I also tried adding the

 apex_json.open_object;  

  apex_json.write('success', true);  

  apex_json.close_object; 

lines to the end of the database procedure, but again, that does not solve the problem.

What can I do?

Kind regards

Geert

Tagged:

Best Answer

  • Geert01
    Geert01 Member Posts: 141 Bronze Badge
    Accepted Answer

    I managed to solve this problem by adding the line sys.htp.p(APEX_JSON.get_clob_output); as last line of the Ajax Callback process.

      apex_json.initialize_clob_output;

      apex_json.open_object;  

      apex_json.write('success', true);  

      apex_json.close_object; 

      sys.htp.p(APEX_JSON.get_clob_output);

Answers

  • Geert01
    Geert01 Member Posts: 141 Bronze Badge
    Accepted Answer

    I managed to solve this problem by adding the line sys.htp.p(APEX_JSON.get_clob_output); as last line of the Ajax Callback process.

      apex_json.initialize_clob_output;

      apex_json.open_object;  

      apex_json.write('success', true);  

      apex_json.close_object; 

      sys.htp.p(APEX_JSON.get_clob_output);