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
PHPCode: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); } }); }
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]. ' '; } } } }


Reply With Quote
Bookmarks