Trying to write a social website where funny pics and videos are posted and people can leave and reat on other comments. So far so good and what I've coded so far works but it always fails on the first click I just don't get it. Debugging info on the browser says I get the right response from the php file but it says the function isn't defined.
A temporary fix is for me to call the function once and have it do nothing but it doesn't work when I call use this them fix for my other php scripts
var postresponse;
var initpost=post('findpics.php'); //fails 1st click if i remove this
function post(php,vars){
$.post(php,vars,function(data){
postresponse=data;
})
return postresponse;
}
$uploadpic.click(function(){
var pics_array=post('findpics.php').split(',');
$pics.empty();
$.each(pics_array, function(val,text) {
$pics.append( $('<option></option>').val(text).html(text) )});
$picbox1.attr('src','/contentuploads/'+$('#pics option:selected').text());
$dgbox.fadeIn(750);
}
);