Blog
Sorry, but nothing was found. Please try a search with different keywords.
function callGeminiAPI(promptData) { const $button = jQuery('#submit-btn'); const $responseArea = jQuery('#response-log'); jQuery.ajax({ url: my_plugin_ajax.ajax_url, // Your WordPress AJAX URL type: 'POST', data: { action: 'gemini_request_action', prompt: promptData, nonce: my_plugin_ajax.nonce }, success: function(response) { if (response.success) { $responseArea.html(response.data.text); } else { handleGeminiError(response.data.message, promptData); } }, error: function(xhr) { // Handle HTTP 503 (Overloaded) or 429 (Rate Limit) if (xhr.status === 503 || xhr.status === 429) { handleGeminiError("Model is overloaded", promptData); } else { $responseArea.html("Error: " + xhr.statusText); } } }); } function handleGeminiError(message, originalData) { let seconds = 60; const $status = jQuery('#status-display'); const timer = setInterval(() => { $status.html(`⚠️ ${message}. Retrying in ${seconds}s...`); seconds--; if (seconds < 0) { clearInterval(timer); $status.html("🔄 Retrying now..."); callGeminiAPI(originalData); // Auto-retry } }, 1000); }
Sorry, but nothing was found. Please try a search with different keywords.