forked from bandid/tiny-gemini-ai-writer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtiny-gemini-ai-writer-admin.js
27 lines (25 loc) · 1.01 KB
/
tiny-gemini-ai-writer-admin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
jQuery(document).ready(function($) {
window.generateTinyGeminiContent = function() {
var prompt = $('#tiny-gemini-ai-prompt').val();
// Show the generating message
$('#tiny-gemini-ai-output').html('<p>Generating content. Please wait a few seconds.</p>');
$.ajax({
url: tiny_gemini_ai_writer.ajax_url,
method: 'POST',
data: {
action: 'generate_tiny_gemini_content',
prompt: prompt
},
success: function(response) {
if (response.success) {
$('#tiny-gemini-ai-output').html('<p>Post created successfully! <a href="' + response.data.edit_link + '">Edit Post</a></p>');
} else {
$('#tiny-gemini-ai-output').html('<p>' + response.data + '</p>');
}
},
error: function() {
$('#tiny-gemini-ai-output').html('<p>An error occurred.</p>');
}
});
};
});