Problem with return $.post
Hello:
I'm having a problem with return data from a $.post. Details follow below:
- The $.post successfully sends data to a .php file.
- The php file successfully processes the data and compiles results into an array. The array is returning in the console.log. When I return one value of the array (instead of the whole array), the value shows up in the console.log.
- However, I can't get pull the values in the array into jQuery for use on my main page. In addition, I know something is off in my $.post routine because console.log and alert commands do not work within the routine.
- I can not pass variable values outside the $.post, either. If I try to pass the variable value to $('#id').html(variable) - the value will not show up. But if I assign a test value to the global variable OUTSIDE of $.post, then it shows up in the $('#id').html().
- However - once outside the $.post function - jQuery resumes normal activity.
- All my variables are declared globally.
- This file is "use strict";
- Below is my $.post function
- $.post("addressbk_data_3.php",{bind_topic:topic_array, bind_participants:rowOwner_array, bind_emails:email_array, bind_salutation:rowContact_array},function(data){
- var_returnData = $.parseJSON(data);
- var_postID = var_returnData.post_id;
- var_topicID = var_returnData.topic_id;
- var_emailCT = var_returnData.email_ct;
- alert("This is the email CT: " + var_emailCT); // This alert is NOT working. But jQuery below this function is continuing to operate as normal.
- });
I am completely stumped and welcome any input others have.
Thanks Much:
Pavilion