"Does anyone know what is wrong?  I've never seen an ordinary function
behave this way. "

That's because $.post (and the resultant $.ajax) isn't "ordinary",
it's an asynchronous call and when you hit the line

 jsonData = eval('(' + data + ')');

the script isn't back from the post call yet....

you need to learn about callbacks to better your code to take full
advantage of async behavior

another tip, if you are doing a post and looking to get back JSON,
then use something like:


var Options = {
    type = "POST",
    url = "save_search.php",
    processData = true,
    data = formData,
    dataType = "json",
    success = SaveSearch_Success,
    error = SaveSearch_Error
};
$.ajax(Options);

and outside all that, here are your functions "outside" the ajax call

function SaveSearch_Success(data) {
   // data = your result in JSON already
};
function SaveSearch_Error(x,y,z) {
   // x.responseText will have server side error message
};

Reply via email to