Results 1 to 10 of 10

Thread: Reading+Processing PHP File outputs

  1. #1
    Join Date
    Apr 2011

    Question Reading+Processing PHP File outputs

    I have resorted to using a forum after 2 days of head scratching. What I need is some script to monitor the output of a php file that outputs "yes" or "no" depending on weather it is your turn in a multiplayer game. I would like it to just check every few seconds (in order to not crash the server) if it has changed. While the PHP file is showing "yes" I want it to show some buttons to make a move and when it is showing "no" for it to just say something like "enemy's turn". I hear that this kind of thing could be achieved with jQuery and AJAX but I have never used JavaScript or AJAX before so that's why I've come here for help.

    I already feel like I'm making a big ask but if you don't mind I would also like a way of submitting your move to a php file to make the move (submitting something to MySql)

    I would really appreciate an answer to both however the first enquiry I consider a priority

  2. #2
    Join Date
    Apr 2011
    I live in the pinaple under the sea
    Ok its like going to somewhere place but you don't know where you should start.
    The first thing you should start is AJAX call

    Ajax is something like accessing server script without reloading page (no page load at all)

  3. #3
    Join Date
    Apr 2011
    I live in the pinaple under the sea
    Another things I have notice. based on what you want to happen. its somethings like you want a client side will response whenever a certain occurrence of a variable that is processing in the server become "YES" right?

    well thats a bit imposible...

    the reason why is because what you want to happen is like your walking upside-down

    in client-server application the server duty is to response to all the request coming from a requesting client browser. means that the browser part is the request and the server is the response. what you want to do is like you turn it upside down lol

    in ajax call the one will trigger some events is on the browser side (a javascript scripts) using ajax call that will call the php or what ever server side program then the server will response and that response will be available on your client side script (javascript)

  4. #4
    Join Date
    Apr 2011
    the PHP file literally processes information and outputs to the user yes or no. As in if you were to visit the page all you would see in the browser would be "yes" or "no". All I want ajax to do is read it like a text file just checking it every so often.

  5. #5
    Join Date
    Apr 2011
    I live in the pinaple under the sea
    Just remember that the client always establish the request and everything will start from it (server will only response to the requesting client and then done)

    you can put the request by using any available events on the client side (like create a timer in javascript and establish a request)

  6. #6
    Join Date
    Apr 2011
    that's kinda what I'm going for. PHP file figures out if it's you're turn and I want Javascript to do check whether it is outputting yes or no and act accordingly. I really need it to ping every 3 or 4 seconds.

  7. #7
    Join Date
    Apr 2011
    I live in the pinaple under the sea
    see this reference it will help you alot


  8. #8
    Join Date
    Apr 2011
    I have looked at lots of reference sites but I am having great trouble understanding it. I would really appreciate some example source code

  9. #9
    Join Date
    Apr 2011
    Just to help get the ball rolling a bit, this is some code I got off the internet and have attempted to adapt it. However, with just about everything I try, it totally failed.

    		<div id="battle"></div>
      // jQuery fires this function when the DOM is loaded and ready to use/manipulate
            // via an HTTP GET action, and sets a function (callback) to run when it receives
            // a message back from the server
    		url : "battlestatus.php",
    		success : function (data) {
    			yourTurn = html(data);
      function doReturnAction(data){
         if( data == "yes" ){
              $('#battle').html( 'HAHA!  Your Turn! GET HIM!<br><form><input name="attack" type="button" value="ATTACK!" /></form>' );
              $('#battle').html( 'Please wait while you Enemy tries to kill you...' );
    What I want this script to do:
    • Every few secconds check what output the php page is giving
    • display some HTML in the specified DIV if it outputs "yes"
    • and if it is outputting "no" display some different HTML

    I hope this clarifies what I need done
    EDIT: jQuery is included from an included php file containing page headers. I only displayed the piece I needed help with

  10. #10
    Join Date
    Apr 2011
    is this thread dead because I really need help with this

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.14080 seconds
  • Memory Usage 2,941KB
  • Queries Executed 15 (?)
More Information
Template Usage (33):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (10)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (73):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates