0

I cant figure out why the this alert() part below is not working when I call it from $.getJSON???

function parseInfo(data)
    {
       alert("getJSON worked");
    }

Firebug says I connecting to the server with a 200 OK code

<!DOCTYPE html>
 <html lang="en">
 <head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script>
   <script type="text/javascript">
       $(document).ready(function(){
                 $.getJSON('getData.php', {'data_id' : 'mysql_data'}, parseInfo);
                 });


function parseInfo(data)
{
    alert("getJSON worked");
}

   </script>
</head>
<body>


<form action="getData.php" method="get">
Name: <input type="text" name="fname" />
<input type="submit" />
</form> 


</body>
b_dev
  • 2,568
  • 6
  • 34
  • 43
  • 2
    What is the response from the call to `getData.php`? Is it valid JSON? – mway Oct 08 '10 at 03:39
  • possible duplicate of [Jquery getJSON to external PHP page](http://stackoverflow.com/questions/790910/jquery-getjson-to-external-php-page) – Hogan Oct 08 '10 at 03:51
  • @mway ...thanks ...no it was not valid .....I think I need to make sure I send an array and not a MyQSL object...thanks – b_dev Oct 13 '10 at 18:09

2 Answers2

0

Couple of things to try.

  1. Try updating your jQuery to 1.4.2.
  2. Change your data code to: { data_id : 'mysql_data'}
  3. Inspect the request/response using firebug. This is invaluable in determining what exactly is being sent & received
Alastair Pitts
  • 19,423
  • 9
  • 68
  • 97
0

Doc here.

PART 1

I think it is best to put the callback directly inside of the getJSON() method.

$(document).ready(function(){
        // DATA IS LOADED FIRST AND PARSED TO GET READY TO ME MAPPED AND PUT INTO SORTABLE TABLES
        $.getJSON("getData.php",
            function(json){
                alert( "Got JSON Data  ");
                //DO STUFF HERE
                    }
                    }

PART 2

I simplified the .php file

getData.php can simply look like this:

$all_tdys = array();
echo json_encode($all_tdys);

PART 3

as @mway warned I made sure to pass an array and not a MySQL object.

b_dev
  • 2,568
  • 6
  • 34
  • 43