www.webdeveloper.com
Results 1 to 2 of 2

Thread: $.post problems

Hybrid View

  1. #1
    Join Date
    Mar 2012
    Posts
    18

    $.post problems

    Hello, I am creating a little trivia game, and i have run into a problem! I am looking to used AJAX's $.post to call on a PHP files and send a VARIABLE over. The problem is the PHP script isnt getting it ive run through my script a few times and it looks to be a problem with the PHP. ANY HELP WOULD BE GREATLY APPRECIATED EVEN IF ITS PUSHING ME IN THE RIGHT DIRECTION! heres my CODE :


    JQUERY/AJAX
    Code:
    function CallQuestionPhp()
    	{
        $.post('rootDir + "_mods/ajax/trivia/" + triviaID', {category: QuestionCategory}, function(result){	
    		if(result.indexOf('~~ERROR~~') > -1){
    			createMessageBox(result.replace(/\~\~ERROR\~\~/gi, ''))
    		
    		}
    		else{
          		$("#trivia_question_body").html(result);
    			
    		}
        });
    	}
    PHP
    Code:
    		
    		if(isset($_POST['category'])){
    			$jscat = $_POST['category'];
    				$categories = db_get_by_sql("SELECT * FROM trivia_categories");
    			foreach($categories as $key => $getcat){
    				
    				if ($jscat = $getcat[id])
    				{
    						$getquestion = db_get_by_sql("SELECT * FROM trivia_types WHERE trivia_category_id = $getcat[id] ORDER BY RAND() LIMIT 1");
    						$out .=' ' .$getquestion['question']. ' ';
    							$answers = db_get_by_sql("SELECT * FROM trivia_answers where trivia_type_id = $getquestion[id] ORDER BY RAND()");
    				foreach($answers as $key1 => $getanswer)
    				{
    					$out.=' ' .$getanswer[name]. ' ';
    				}
    				}
    			}
    		}

  2. #2
    Join Date
    Mar 2012
    Posts
    18
    I have found the problem! My head developer forgot to inform me of the outdated version of the CMS i was using. The problem had to do with the htacess file blocking the $_POST out. Thank you everyone!

Thread Information

Users Browsing this Thread

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

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



Recent Articles