Completed
Last Updated: 27 Feb 2025 13:51 by ADMIN
Release 2025 Q2 (May)
Chris
Created on: 26 Feb 2025 21:58
Category: Spell
Type: Bug Report
0
Uncaught SyntaxError: Unterminated string in JSON

We have the latest update for Ajax installed today and have found an issue with the RadSpell control. If you type a value of 'tha' into a textbox/text area control that spell check will target, you will get an error 'Uncaught SyntaxError: Unterminated string in JSON' error in the console. This is able to replicated within the demo page of the Spell control.

https://demos.telerik.com/aspnet-ajax/spell/examples/overview/defaultcs.aspx?_gl=1*19wdrka*_gcl_au*NTA5NTg2MDEuMTc0MDYwNDU5NQ..*_ga*MjA4NzU2NTg4MC4xNzQwNjA0NTkx*_ga_9JSNBCSF54*MTc0MDYwNDU5MS4xLjEuMTc0MDYwNjI5Mi42MC4wLjA.

Remove the text in the first textbox in this page and replace it with 'tha' and in the console you will see the error shoot off.

1 comment
ADMIN
Rumen
Posted on: 27 Feb 2025 13:44

Hi Chris,

Thank you for reporting this issue! I’ve reproduced it and converted the ticket into a public bug report so that other users experiencing the same problem will be notified.

In the meantime, please try one of the following workarounds:
  • Switch the spellchecker provided to EditDistance: SpellCheckProvider="EditDistanceProvider"
  • If you prefer to keep using the default spell check provider, you can patch the client-side script. Save the following code in a file (e.g., scripts.js) and load it via the DialogsScriptFile="scripts.js"

    ASPX
    <telerik:RadTextBox ID="RadTextBox1" Text="tha" runat="server"></telerik:RadTextBox>
    <telerik:RadSpell DialogsScriptFile="scripts.js" ID="RadSpell1" runat="server" ControlsToCheck="RadTextBox1"></telerik:RadSpell>

    script.js
        Telerik.Web.UI.SpellCheckService.prototype._processResponse = function(executor, args) {
                    var statusCode = executor.get_statusCode();
    
                    if (executor.get_responseAvailable() && 200 == statusCode && executor.get_responseData().length > 0) {
                        var result = executor.get_object();
        alert(1)
        if (result.badWords != null) {
                            var jsonCompatible = result.badWords;
        jsonCompatible = jsonCompatible.replace(/([{,]\s*)([a-zA-Z0-9_]+)\s*:/g, '$1"$2":');
        jsonCompatible = jsonCompatible.replace(/'((?:\\.|[^\\'])*)'/g, '"$1"');
        jsonCompatible = jsonCompatible.replace(/\\'/g, "");
    
        result.badWords = JSON.parse(jsonCompatible);
                        }
    
        if (result.wordOffsets != null) {result.wordOffsets = JSON.parse(result.wordOffsets); }
    
        this.raise_complete(executor.get_object());
                    } else {
                        if (executor.get_timedOut()) {
            alert('Spell Check Request time out');
                        } else if (executor.get_aborted()) {
            alert('Spell Check Request aborted');
                        } else if (404 == statusCode) {
            window.alert('Web.config registration missing!\n The spellchecking functionality requires a HttpHandler registration in web.config. Please, use the control Smart Tag to add the handler automatically, or see the help for more information.\n\n' + this.get_url());
                        } else if (statusCode > 0 && statusCode != 200) {
            window.alert('Spell Check Handler Server Error:' + statusCode + '\n' + executor.get_responseData());
                        }
                    }
                }
    

As a small token of gratitude for your contribution, your Telerik points have been updated. We appreciate your help in improving our product!

Regards,
Rumen
Progress Telerik

Enjoyed our products? Share your experience on G2 and receive a $25 Amazon gift card for a limited time!