HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

JSON Error with Vanilla 2.0.18.12

AnonymooseAnonymoose ✭✭
edited August 2014 in Feedback

When posting a discussion, this appears:

Questions that may already have your answer:
parsererror (SyntaxError: JSON Parse error: Unrecognized token '<')

Comments

  • Options
    AnonymooseAnonymoose ✭✭
    edited August 2014

    Temporary solution: Remove the related post functionality.

    Replace contents of plugins/SphinxSearch/widgets/views/relatedpost.php

    with:

    <?php
    if (!defined('APPLICATION'))
        exit();
    
    /**
     *FUNCTIONALITY DISABLED, Replace with original relatedpost.php to restore.
     *
     *Insert this below the "Ask and question/disuccion" buttons
     *
     * This will peform a POST to your server asking for related threads as the user
     * types in his/her title
     *
     * @todo make it faster and work with Vanilla's default jquery autocomplete and NOT jqueryUI
     */
    
  • Options

    you shouldn't end a php file with ?> it is open to white space errors.

    grep is your friend.

  • Options
    AnonymooseAnonymoose ✭✭
    edited August 2014

    @x00 said:
    you shouldn't end a php file with ?> it is open to white space errors.

    Thanks. Fixed.

  • Options

    Better way to debug is figure out what you are getting back by looking the network traffic in inspect. That will tell you what you are getting instead of the JSON.

    grep is your friend.

  • Options
    mcu_hqmcu_hq yippie ki-yay ✭✭✭
    edited August 2014

    @Anonymoose Thanks for the bug report

  • Options
    jamesincjamesinc Sydney ✭✭
    edited September 2015

    I'm also seeing this in 2.1.11. As far as I can see, the cause is as follows.

    A JS function, waitForMsg(), builds the URL to /plugin/sphinxsearch/newdiscussion

    This function relies on a value from a DOM node, $("#WebRoot").val().

    I don't appear to have that element in my DOM anywhere, and I'm guessing old mate up above has the same issue. The result is that the plugin attempts an AJAX call to /undefined/plugin/sphinxsearch/newdiscussion. This returns an HTML page and results in the '<' syntax error mentioned above.

  • Options
    jamesincjamesinc Sydney ✭✭

    I think the correct way to do what you're trying to do is as follows:

    gdn.url('/plugin/sphinxsearch/newdiscussion');
    
  • Options
    x00x00 MVP
    edited September 2015

    Yes that was removed from the dom for security reasons.

    Your function is correct usage. For general definitions use gdn.definition

    grep is your friend.

  • Options

    Hi, when i create a new discussion, i still get this:

        Questions that may already have your answer:
    
        parsererror (SyntaxError: Unexpected token < in JSON at position 0)
    

    How to fix that?

Sign In or Register to comment.