The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AJAX and Userspice: No JSON respose
#1
Hey guys,
I am messing around with some AJAX in combination with a form right now...and I ran into something, that I can't make any sense of. I am following this Tutorial: https://scotch.io/tutorials/submitting-a...ver-errors

Everything works according to the example in the tutorial, but once I start to interact with the database, and include

require_once 'users/init.php';
require_once $abs_us_root.$us_url_root.'users/includes/header.php';

into the .php file, my JSON response is all messed up :/

Any tips?
Thanks a lot!
-FLo
  Reply
#2
Where is the location of the file you're creating?
  Reply
#3
Thanks for the quick response!

I just put the file in the root directory Smile
  Reply
#4
It's probably messed up because of the header, there is some data within the header that is probably outputted. I would include init only.
  Reply
#5
Yea, I tried that as well, and the JSON response looks good after excluding the header, but then I always get an Internal Server Error (500) when interacting with a database :O Am I missing something?
  Reply
#6
Alright...I think I solved it myself: A simple $db = DB::getInstance(); instead of including the entire header did the trick! Wink

Thanks a lot for the quick responses though, you guys are awesome!! Smile
  Reply
#7
(01-24-2018, 03:06 PM)Brandin Wrote: It's probably messed up because of the header, there is some data within the header that is probably outputted. I would include init only.

Sad  I'm newBie can't get that.... not loading Ajax input form..... This is all in my header.php...  Instead of form showin blank screen... uploaded form


Code:
<!DOCTYPE html>
<html lang="en">
   <head>

       <title> Pan Card</title>

       <link href="css/bootstrap.css" rel="stylesheet" type="text/css" media="screen">
   
       <link rel="stylesheet" type="text/css" href="css/DT_bootstrap.css">
        
       <link href="modal/css1/bootstrap1.css" rel="stylesheet" type="text/css" media="screen">
 

</head>
<script src="modal/js1/jquery1.js" type="text/javascript"></script>
<script src="modal/js1/bootstrap1.js" type="text/javascript"></script>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
   


<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/bootstrap.js" type="text/javascript"></script>

<script type="text/javascript" charset="utf-8" language="javascript" src="js/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8" language="javascript" src="js/DT_bootstrap.js"></script>


Attached Files Thumbnail(s)
   
  Reply
#8
finally able to run my ajax by removing following codes from top of lines
require_once $abs_us_root.$us_url_root.'users/includes/header.php';
require_once $abs_us_root.$us_url_root.'users/includes/navigation.php';
  Reply
#9
Sorry I just noticed this. The problem with your ajax is that something was being echoed to the screen. Ajax parsers just get the init.php and that's why init doesn't echo anything. Thanks for letting us know.
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)