Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6338849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:31:41+00:00 2026-05-24T19:31:41+00:00

Using jQuery to make an AJAX call to a PHP file results in the

  • 0

Using jQuery to make an AJAX call to a PHP file results in the following error in Chrome only: SyntaxError: Unexpected token ILLEGAL

jQuery Snippet:

 $.ajax({
    type: 'POST',
    url: 'ajax/Test_Get.php',
    dataType: 'json',
    data: {
        ID: settings.ID
    },
    success: function(data) {
        console.log('ok');
    },
    error: function(XMLHttpRequest, textStatus, errorThrown) {
    }
        console.log('error');
    });

PHP Snippet:

...
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-Type: application/json; charset=utf-8');

require_once('../classes/Database.php');
require_once('../classes/Test.php');
...

I spent hours researching this issue and there are a few posts on stackoverflow that talk about problem characters etc. but I haven’t been able to solve this.

The specific problem here appears to be having another <?php block on the page (whether it be as part of an include file or added directly to the page). So because the Test.php file has a <?php block in it I can’t include this class. Other browsers work just fine but not Chrome.

The only bad work around I’ve been able to find is to copy and paste the class code directly within the existing <?php block on the page. This just doesn’t seem right — there must be something fundamental I’m missing here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:31:41+00:00Added an answer on May 24, 2026 at 7:31 pm

    The problem was caused by a single space before the opening php tag in the include file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using wordpress. I make a ajax call with jQuery, PHP echos out a
Help! I am using jQuery to make an AJAX call to fill in a
I am using .Net framework 2.0 / jQuery to make an Ajax call to
I am using the $.ajax function in jquery to make a call to an
I make an AJAX request like so using JQuery: $.ajax({ type: GET, url: getvideo.php,
I am using jQuery to make an AJAX call. The call is procesed and
How to make ajax call on multiple select box using jquery? Any suggestions or
I'm using JQuery with CodeIgniter PHP to figure make AJAX calls and return data
I am using jQuery to make an AJAX request to a remote endpoint. That
I am using jQuery to make some ajax calls and wonder how people handle

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.