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

  • SEARCH
  • Home
  • 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 7091961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:15:11+00:00 2026-05-28T08:15:11+00:00

I am struggeling with a Jquery post call that returns SyntaxError unexpected token if

  • 0

I am struggeling with a Jquery post call that returns SyntaxError unexpected token if I try to require_once the needed files to instantiate the php object and get the propertie of that object. What is weird is that it seems to be working on my remote server but not on my local testing server. Here is the code:

Part of the php file making the Jquery call:

   <script type="text/javascript">   getSelectData()  </script>  
   <!--  Dynamiclygenerate the emailadress for the first referens in the list -->
        <div id="customer_ref_id">

        <label for="customer_name">Kund:</label>
        <p><?php echo $customer->customer_name; ?> </p>

        <a href="#" class="toprghtimg"> <img src="../images/back.png"/></a>

        <p class="instruction">
        Välj Kundreferens i listan nedanför.
        Finns ej din referens så skapa en ny referens knuten till
        kunden genom att klicka på knappen nere till höger.
        </p>
        <div class="clearLeft"></div>
        <label for="customer_ref_id">Kundreferens:</label>
        <select name="customer_ref_id"  id="customer_ref_id">
            <?php
            foreach ($customerRefs as $customerRef) { ?>
            <option value="<?php echo $customerRef->id; ?>">
            <?php echo $customerRef->full_name(); ?>
            </option>
            <?php } ?>
        </select>


     <input type="button" value="Skapa ny Kundreferens" onclick="getNewCustRef()" />
     <div class="clearLeft"></div>
    <div id="customerRefInfo"> <label>E-post:</label><p>-Ej registrerad-</p></div>
    <input type="button" class="after_p" value="Ändra referensens data" onclick="changeRefData()" />
   </div>

This is the getNewCustRef() function :

function getSelectData() {

  var formData = $("#customer_ref_id select").serialize();

        $.ajax({
            url     : 'getSelectData.php',
            type    : 'POST',
            dataType: 'json',
            data    : formData,
            success: function( data ) {

              $('#customerRefInfo p').replaceWith('<p>'+data+'</p>' )  ;

            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {

                alert(errorThrown); }
        });

}

And this is the getSelectData.php file that I can´t get to require the needed function file:

<?php require_once("../../includes/initialize.php");
$customer_ref_id = $_POST['customer_ref_id']; // Selected customer_ref_id

$custRef = CustomerRef::find_by_id($customer_ref_id);
$custRefEmail = $custRef->e_post;

echo json_encode($custRefEmail);

?>

If I comment out the require once and set $custRefEmail = $customer_ref_id It returns the ID that got sent in by the post function. So the data gets there allright. It all fails when I try to include any file… ??? And yes I have spent hours on this googling and looked in here at all sorts of questions…. Iam depserate for help…

  • 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-28T08:15:12+00:00Added an answer on May 28, 2026 at 8:15 am

    You should run a phpinfo(); to see that both PHP versions include JSON support and all of the other needed libraries.

    Then I’d double check to make sure that the file is in the directory that is being looked at. In this case, it’s the grandparent directory (../../file.php).

    I’d then create a couple of files to see if I could get the include / require_once functions to work.

    Sometimes working with remote/local you can easily get mixed up. Just today I was editing a local copy of a file and tearing my hair out because the remote file wasn’t showing any changes!

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

Sidebar

Related Questions

I'm fairly new to jquery and struggling with something that should be fairly simple.
I am currently trying to hook up jQuery UI dialog so that I may
I want to do the jQuery POST every 5 seconds with different POST values
i'm sending values from one page via jquery's ajax to a php page. I'm
I have been struggling to get my jquery call to a webmethod to work.
I've been struggling to find a jQuery alternative that does exactly the same as:
I can successfully post an array to PHP using Ajax Post but I want
I'm trying to get some rollovers working using jQuery. The trouble is that the
I'm struggling to find the right terminology here, but if you have jQuery object...
I'm struggling with the following problem. I use the jQuery autocomplete plugin to get

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.