Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

JSON Error with Vanilla 2.0.18.12

This discussion is related to the SphinxSearch addon.
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

  • 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
     */
    
    UnderDog
  • you shouldn't end a php file with ?> it is open to white space errors.

    grep is your friend.

    hgtonightmcu_hqperegrineUnderDog
  • AnonymooseAnonymoose ✭✭
    edited August 2014

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

    Thanks. Fixed.

    UnderDog
  • 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.

    UnderDog
  • mcu_hqmcu_hq yippie ki-yay Arizona, USA ✭✭✭
    edited August 2014

    @Anonymoose Thanks for the bug report

    UnderDog
  • 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.

  • jamesincjamesinc Sydney ✭✭

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

    gdn.url('/plugin/sphinxsearch/newdiscussion');
    
  • 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.

  • 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.