Uncaught SyntaxError: Unexpected end of JSON input

QuestionsUncaught SyntaxError: Unexpected end of JSON input
Michael Sheppard asked 6 years 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 6 years 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
Grid 4 PHP Framework
 
Michael Sheppard replied 6 years 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

2 + 14 =

Login with your Social Id:

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 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

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

Let us improve this post!

Tell us how we can improve this post?