Support » Plugin: Forms: 3rd-Party Integration » ‘Unexpected token < in JSON at position 0' echoed after posting

  • Hello Zaus and everybody,

    I’m integrating with an auto-responder service, and my goal is to catch the response,
    extract the success url, and redirect to it.

    Integration works OK (thanks for the great plugin by the way), so now I simply need
    to catch the response, grab (somehow) the url which is in the ‘Location’ parameter of
    the response header and redirect user to it: (‘Location” just below the red frame):
    https://i0.wp.com/s24.postimg.org/5pzakublx/Screen_Shot_2016_12_16_at_12_38_01_AM.png?ssl=1

    For that purpose, I created a custom action using the 3rd-party folder to aid me in creating the code (mailchimp code – thanks for this too, was very helpful to a noob like me!), and after saving my functions.php went ahead and made a submission.

    What happened?
    The submissions was once again successfully delivered to the 3-rd party, and in addition, I’m getting ‘Unexpected token < in JSON at position 0’ just beneath my form a few secs after clicking ‘Submit’:
    https://i1.wp.com/s24.postimg.org/49ns2p8p1/Screen_Shot_2016_12_16_at_12_38_54_AM.png?ssl=1
    THe post arrives at the 3rd party OK and the action fails.

    According to this:
    http://stackoverflow.com/questions/37280274/syntaxerror-unexpected-token-in-json-at-position-0-in-react-app

    it seems that server is returning Content-Type: text/html while plugin is expecting JSON.
    Could that be correct?
    https://i0.wp.com/s24.postimg.org/5pzakublx/Screen_Shot_2016_12_16_at_12_38_01_AM.png?ssl=1

    Am I missing something?
    How can I make theis awesome plugin receive non JSON response and extract the Location param value from the header?

    Thanks a lot, your help much appreciated
    Yosi

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author zaus

    (@zaus)

    The new message you’re seeing is the Ajax response from cf7 with a PHP warning or something in what should be json. There’s probably something “wrong” with your hook – open the browser dev tools (inspect or f12) and check out the “network” or “console” tab before you submit the form to see what it’s returning.

    Thanks zaus, I found a JS way to submit to another form – hope this helps someone in the future 🙂
    Cheers!
    Yosi

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘‘Unexpected token < in JSON at position 0' echoed after posting’ is closed to new replies.