Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ajax call to a php file not working with 'require_once' in that file

Tags:

jquery

ajax

php

I basically have an ajax call to a php file:

$("#acceptBtn").click(function(){
     $.ajax({
     type: "POST",
     url:"acceptOfferFunction.php",
     data: {hash2: getURLParameter('hash2')},
     success:function(result){
         alert(result);
     }
});

And for the sake of clarity here's the reduced version of that file illustrating the problem:

<?php
     session_start();   
   //require_once 'AcceptAnOfferFromEditor.php';
     echo('foo');
 ?>

This works, 'foo' gets alerted, but should I uncomment the require_once statement, it doesn't anymore.

The included file is a php class with many functions. It would be convenient to able to call them.

like image 767
ZviBar Avatar asked Jan 15 '23 00:01

ZviBar


1 Answers

There is likely an error in your required file. Enable error reporting to debug this:

<?php
    session_start();   
    ini_set('display_errors', 1);
    error_reporting(E_ALL);
    require_once 'AcceptAnOfferFromEditor.php';
    echo('foo');

Alternatively there might be a die() or exit call in the file.

like image 106
Michael Robinson Avatar answered Jan 19 '23 12:01

Michael Robinson