Uncaught SyntaxError: Unexpected end of JSON input

QuestionsUncaught SyntaxError: Unexpected end of JSON input
Michael Sheppard asked 1 year ago

Using the Custom Event sample from demos, I am trying to update two tables at the same-time using a custom SQL update. The query has a join on two tables. Everything works correctly during an inline edit.
However – if I use the pop-up Edit window it works when I hit submit – but the Edit Modal window does not go away and I get an error “Uncaught SyntaxError: Unexpected end of JSON input” on the error-console (Chrome and Firefox).
It seems as though this line is where it’s failing:
       var data = JSON.parse(response.responseText;
I am unsure how to solve this issue. Do you have any suggestions? It almost seems like the custom event handler needs a way to send a valid response to the Modal on Submit.
 
Thanks for any help.
 

1 Answers
Abu Ghufran Staff answered 1 year ago

In your custom event callback function … you need to return following before function end.

$res = array(“id” => 0, “success” => true);
echo json_encode($res);
die;

_________________________
Abu Ghufran - Dev Team
PHP Grid Framework
 
Michael Sheppard replied 1 year ago

This code didn’t work when I added it to the update-data function. I couldn’t find this example in your demo-code, so I looked in jqgrid_dist and found-it there. I reviewed the code and realize with the custom event handler $res is not getting set.

I see further-on you have a function for phpgrid_msg with options for confirmation text and fade
. . . I tried setting a custom message after the update and this worked.

$g->execute_query($str);
phpgrid_msg(“Insert Successful”,1);

Thank you for pointing me in the right direction.

Your Answer

13 + 20 =

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating / 5. Vote count:

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!