Fix jQuery issue in my Wordpress plugin
Budget: $10 – $30 USD
I have an issue with my Wordpress plugin. Specifically in the jQuery part where i am fetching data from an external API and displaying it inside a textarea. The issue is: if i delete all response from textarea and call the api again, response is not being append to textarea. From console log i can see that i am getting the response from api but not appending. Can you fix this issue?
Below is the script:
<script type="text/javascript" >
jQuery(document).ready(function($) {
jQuery('.lds-ellipsis').hide();
jQuery('#load_plugin_settings').on('click',function(e){
var wpai_preview_title = $("#wpai_preview_title").val();
var wpai_number_of_heading = $("#wpai_number_of_heading").val();
var wpai_add_img = $("#wpai_add_img").val();
console.log("prompt input",wpai_preview_title)
e.preventDefault();
jQuery('.lds-ellipsis').show();
var data = {
'action': 'wpaicg_load_values',
'ai_post_id': '<?php echo esc_html($post->ID); ?>',
'wpai_preview_title': wpai_preview_title,
'wpai_number_of_heading': wpai_number_of_heading,
'wpai_add_img': wpai_add_img,
};
jQuery.post(ajaxurl, data, function(response) {
jQuery('#preview_box').html(response);
jQuery('.lds-ellipsis').hide();
console.log(response)
});
});
});
</script>
Below is the script:
<script type="text/javascript" >
jQuery(document).ready(function($) {
jQuery('.lds-ellipsis').hide();
jQuery('#load_plugin_settings').on('click',function(e){
var wpai_preview_title = $("#wpai_preview_title").val();
var wpai_number_of_heading = $("#wpai_number_of_heading").val();
var wpai_add_img = $("#wpai_add_img").val();
console.log("prompt input",wpai_preview_title)
e.preventDefault();
jQuery('.lds-ellipsis').show();
var data = {
'action': 'wpaicg_load_values',
'ai_post_id': '<?php echo esc_html($post->ID); ?>',
'wpai_preview_title': wpai_preview_title,
'wpai_number_of_heading': wpai_number_of_heading,
'wpai_add_img': wpai_add_img,
};
jQuery.post(ajaxurl, data, function(response) {
jQuery('#preview_box').html(response);
jQuery('.lds-ellipsis').hide();
console.log(response)
});
});
});
</script>