The following warnings occurred: | ||||||||||||
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
|
AJAX and Userspice: No JSON respose - Printable Version +- UserSpice (https://userspice.com/forums) +-- Forum: Miscellaneous (https://userspice.com/forums/forumdisplay.php?fid=28) +--- Forum: Off-topic Discussions (https://userspice.com/forums/forumdisplay.php?fid=10) +--- Thread: AJAX and Userspice: No JSON respose (/showthread.php?tid=920) |
AJAX and Userspice: No JSON respose - flo - 01-24-2018 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-ajax-forms-with-jquery#toc-showing-server-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 AJAX and Userspice: No JSON respose - Brandin - 01-24-2018 Where is the location of the file you're creating? AJAX and Userspice: No JSON respose - flo - 01-24-2018 Thanks for the quick response! I just put the file in the root directory AJAX and Userspice: No JSON respose - Brandin - 01-24-2018 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. AJAX and Userspice: No JSON respose - flo - 01-24-2018 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? AJAX and Userspice: No JSON respose - flo - 01-24-2018 Alright...I think I solved it myself: A simple $db = DB::getInstance(); instead of including the entire header did the trick! Thanks a lot for the quick responses though, you guys are awesome!! RE: AJAX and Userspice: No JSON respose - shakty - 10-21-2018 (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. 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> RE: AJAX and Userspice: No JSON respose - shakty - 10-21-2018 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'; RE: AJAX and Userspice: No JSON respose - mudmin - 10-23-2018 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. |