Quite well versed in PHP, newer to AJAX/json/jQuery.
Primary Page
Quote:
<html>
<head>
<script type="text/javascript" src="../resources/jQuery/jquery-1.7.2.min.js"></script>
</head>
<body>
<div id="output">Change me</div>
<?
$data = array("task" => "getuniqueid" ,"id" => "3");
?>
<script id="source" language="javascript" type="text/javascript">
$(function ()
{
$.ajax({
url: '../resources/ajax.api.php',
data: <? echo json_encode($data); ?>,
dataType: 'json',
success: function(data)
{
var task = data[0];
var id = data[1];
//Change div
$('#output').html("<b>Task:</b>"+task+"<b> ID: </b>"+id);
}
});
});
</script>
</body>
</html>
|
ajax.api.php
Quote:
<?php
chdir('..');
include('includes/global.php');
if($_GET['task']==getuniqueid)
{
$player = new player();
echo json_encode($player->getuniqueID($_GET['id']));
}
?>
|
Output:
Task:undefined ID: undefined
If I manually visit the page with the parameters passed in the URL,I do get the proper json output.
I have also tried setting the data to

Unsuccessful)
"task=getuniqueid&id=3"
Any & all help is appreciated.
Thank you.