1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

handling xenforo javascript error for curl response

Discussion in 'XenForo Development Discussions' started by Jarvis, May 16, 2016.

  1. Jarvis

    Jarvis New Member

    I'm running a POST curl after a user submits a form, however the response I get from the request gives me a java error that displays on the page as:

    The following error occurred
    The server responded with an error. The error message is in the JavaScript console.

    How can I have the xenforo JS just ignore the response and now throw me an error?

    For reference, here is my PHP code:


    PHP:
            $ch  curl_init();
            
    curl_setopt($chCURLOPT_URL$url );
            
    curl_setopt($chCURLOPT_HTTPHEADER$header);
            
    curl_setopt($chCURLOPT_CONNECTTIMEOUT5);
            
    curl_setopt($ch,CURLOPT_FOLLOWLOCATIONfalse);
            
    curl_setopt($chCURLOPT_CUSTOMREQUEST"POST");
            
    curl_setopt($chCURLOPT_USERAGENT,'My App');
            
    curl_setopt($chCURLOPT_POSTFIELDS$data_string);
            
    $response curl_exec($ch);
            
    curl_close($ch);
     
  2. Jarvis

    Jarvis New Member

    I found out this is due to the xenforo debugging javascript.

    On live, this works fine.
     
  3. Jarvis

    Jarvis New Member

    Hmm...

    It's throwing the error again. The only 'error' is the API response.
     

Share This Page