Page 1 of 1

[SOLVED] Json on php side after getJSON call

Posted: Mon Aug 13, 2012 12:26 pm
by vlio20
Hi,
Hi,
I have an issue with the getJSON method, here is the code of the jquery:

Code: Select all


$(document).ready(function(){
 $.getJSON('../php/functions/user_info.php', {id: id}, function(data){
 alert(data);
 });
});

the php code at ../php/functions/user_info.php is:

Code: Select all


<?php
require_once 'connection.php';
$link = conenct('localhost', 'root', '', 'w_db');

mysql_query( "SET NAMES utf8" );
mysql_query( "SET CHARACTER SET utf8" );
mysql_set_charset('utf8', $link);

$id = $_POST['id'];
$id = mysql_real_escape_string($id);

$query = mysql_query("SELECT * FROM users WHERE id = '$id'") or die('Invalid query:'. mysql_error());
$userInfo = mysql_fetch_assoc($query);

echo json_encode($userInfo );
?>

When I am running the page no alert pops out. What is wrong with my code?!?!?

tnx!!

Re: Json on php side after getJSON call

Posted: Mon Aug 13, 2012 12:31 pm
by vlio20
got it!
on the php side it suppose to be

Code: Select all

$id = $GET['id'];