mysteriousmonkey29 Posted July 24, 2016 Share Posted July 24, 2016 Hello, I am trying to create a simple RSS reader using HTML 5, JavaScript+jQuery+jFeed, and now, PHP. I originally was not using PHP, but then I ran into a cross domain request issue when trying to access an RSS feed (I am using the web comic XKCD as a test) with the following script in the body: <!--include jQuery--> <script type="text/javascript" src="jquery-3.0.0.js"></script> <!--include jFeed--> <script type="text/javascript" src="jfeed.js"></script> <script type="text/javascript"> jQuery.getFeed({ url: 'http://xkcd.com/rss.xml' success: function(feed) { alert('jFeed test'); alert(feed.title); } }); </script> which produces the following error: XMLHttpRequest cannot load http://xkcd.com/rss.xml. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8383' is therefore not allowed access. (18:01:48:198 | error, javascript) at public_html/index.html which after research, is supposedly solvable by using a PHP server proxy to forward the RSS page to the client side of my website. So I added the following PHP file to my project (my attempt at a proxy, basically just copied from examples online): <?php // Set your return content type header('Content-type: application/xml'); // Website url to open $url = 'http://xkcd.com/rss.xml'; // Get that website's content $handle = fopen($url, "r"); // If there is something, read and return if ($handle) { while (!feof($handle)) { $buffer = fgets($handle, 4096); echo $buffer; } fclose($handle); } ?> And then changed the RSS URL in the HTML code to that of my PHP proxy file, so that it now reads: url: 'localhost/XKCD_proxy.php', However, when I test tthis on my local server using XAMPP, nothing happens--no jQuery dialogues, as included in the success function. I also don't get any errors so I'm pretty confused. Anyone know what I'm doing wrong? Thanks in advance Link to comment Share on other sites More sharing options...
thescientist Posted July 25, 2016 Share Posted July 25, 2016 Are you looking in the error console of your browser? Check to see if the request for the file is going out and what the response is. I would also add logging to your PHP and Javascript so you can trace the execution of the code. Link to comment Share on other sites More sharing options...
mysteriousmonkey29 Posted July 25, 2016 Author Share Posted July 25, 2016 Okay, I opened up chrome development tools and looked in the error console and there was an error. I'm not sure what you mean by the file request and response, and I'm also not sure how to add logging to PHP and JavaScript. I'm using NetBeans 8. However, I did look up a video of how Xdebug is supposed to work with NetBeans (probably should've done this earlier): When I run my code with a breakpoint like in the video, I browser does not pause. I am allowed the option to stop debugging, but this step through buttons are all greyed out. any idea why this is happening? It seems like I have the debugger installed, but that it's not functioning correctly Link to comment Share on other sites More sharing options...
justsomeguy Posted July 25, 2016 Share Posted July 25, 2016 It sounds like your IDE isn't talking to your web server, there might be a missing connection there to enable debugging. Are you sure that XDebug is installed and configured correctly on PHP? Link to comment Share on other sites More sharing options...
mysteriousmonkey29 Posted July 25, 2016 Author Share Posted July 25, 2016 I'm not sure; how would I tell? I'm trying to post the output by PHP info here but it's too long Link to comment Share on other sites More sharing options...
justsomeguy Posted July 25, 2016 Share Posted July 25, 2016 Do you see an XDebug section in the phpinfo listing? Link to comment Share on other sites More sharing options...
mysteriousmonkey29 Posted July 26, 2016 Author Share Posted July 26, 2016 Yes, this is what that section says: xdebug xdebug support enabled Version 2.4.0 IDE Key Randy Supported protocols Revision DBGp - Common DeBuGger Protocol $Revision: 1.145 $ Directive Local Value Master Value xdebug.auto_trace Off Off xdebug.cli_color 0 0 xdebug.collect_assignments Off Off xdebug.collect_includes On On xdebug.collect_params 0 0 xdebug.collect_return Off Off xdebug.collect_vars Off Off xdebug.coverage_enable On On xdebug.default_enable On On xdebug.dump.COOKIE no value no value xdebug.dump.ENV no value no value xdebug.dump.FILES no value no value xdebug.dump.GET no value no value xdebug.dump.POST no value no value xdebug.dump.REQUEST no value no value xdebug.dump.SERVER no value no value xdebug.dump.SESSION no value no value xdebug.dump_globals On On xdebug.dump_once On On xdebug.dump_undefined Off Off xdebug.extended_info On On xdebug.file_link_format no value no value xdebug.force_display_errors Off Off xdebug.force_error_reporting 0 0 xdebug.halt_level 0 0 xdebug.idekey no value no value xdebug.max_nesting_level 256 256 xdebug.max_stack_frames -1 -1 xdebug.overload_var_dump On On xdebug.profiler_aggregate Off Off xdebug.profiler_append Off Off xdebug.profiler_enable Off Off xdebug.profiler_enable_trigger Off Off xdebug.profiler_enable_trigger_value no value no value xdebug.profiler_output_dir \ \ xdebug.profiler_output_name cachegrind.out.%p cachegrind.out.%p xdebug.remote_addr_header no value no value xdebug.remote_autostart Off Off xdebug.remote_connect_back Off Off xdebug.remote_cookie_expire_time 3600 3600 xdebug.remote_enable Off Off xdebug.remote_handler dbgp dbgp xdebug.remote_host localhost localhost xdebug.remote_log no value no value xdebug.remote_mode req req xdebug.remote_port 9000 9000 xdebug.scream Off Off xdebug.show_error_trace Off Off xdebug.show_exception_trace Off Off xdebug.show_local_vars Off Off xdebug.show_mem_delta Off Off xdebug.trace_enable_trigger Off Off xdebug.trace_enable_trigger_value no value no value xdebug.trace_format 0 0 xdebug.trace_options 0 0 xdebug.trace_output_dir \ \ xdebug.trace_output_name trace.%c trace.%c xdebug.var_display_max_children 128 128 xdebug.var_display_max_data 512 512 xdebug.var_display_max_depth 3 3 xml XML Support active XML Namespace Support active libxml2 Version 2.9.4 xmlreader XMLReader enabled Link to comment Share on other sites More sharing options...
justsomeguy Posted July 26, 2016 Share Posted July 26, 2016 OK, so it sounds like it's enabled. If you're following a guide to integrate it with your IDE, the things I would look at are to make sure that the host and port are correct, the IDE key is correct, and the various settings for enabling or disabling XDebug. The options for xdebug.profiler_enable and xdebug.remote_enable are disabled, for example. Link to comment Share on other sites More sharing options...
thescientist Posted July 26, 2016 Share Posted July 26, 2016 for simple logging Javascript console.log("i made it here"); PHP echo "i made it here too"; For request / response, use the browsers developers tools and the network tab. All requests going out from the browser will be there and you can see if they were successful or not Link to comment Share on other sites More sharing options...
mysteriousmonkey29 Posted July 27, 2016 Author Share Posted July 27, 2016 Thanks for the logging and request response information; I'll check that stuff out. As for the Xdebug stuff, I will check on those settings, thanks. The weird thing though is that when I run projects in debug mode from NetBeans, I don't get any error messages, and I get something appended to the URL indicating that an Xdebug session is started. It's like it's enabled but not working Link to comment Share on other sites More sharing options...
justsomeguy Posted July 27, 2016 Share Posted July 27, 2016 That's one way to enable Xdebug, with a URL parameter. It's been a while since I've read through the documentation to see how everything works though. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now