Forum in maintenance, we will back soon 🙂
The UI and The PHP Code
I watched your recent Video About Building A Blog Title Generator As Example But I have My Own Gemini API Key and I did as You did In The Video Both Code Which UI and PHP Code Is Not Working I installed The Wp-code Plugin Which You recomended in The Video But The UI image and PHP functions Are.......Dead See the Below image I know my English I hope You Understand it
 or You Can See it in this link https://muhtadun.com/blog-title-generator/
@google-businessgmail and @badrsabra, see lines 92, 113, 119, 141 and 146 of the file posted at https://learnwithhasan.com/custom-code/ai-tool-on-wordpress-ui/ where you need to change the URL
Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack
@ssadvisor thank you very much for your kindness you here every time i ask about anything
@ssadvisor fetch('http://wordpress-test.local/wp-admin/admin-ajax.php', {
with this code what should i do i write it like that
fetch('http://ai.superseotools.net/wp-admin/admin-ajax.php', {Â
but i get erorr
<style> body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #f4f4f4; color: #333; line-height: 1.6; padding: 20px; } .container { max-width: 600px; margin: auto; background: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); text-align: center; } .input-group { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; } input[type="text"] { flex-grow: 1; padding: 10px; border: 1px solid #ddd; border-radius: 4px; margin-right: 10px; } button { background: #007bff; color: #fff; border: 0; padding: 10px 20px; border-radius: 4px; cursor: pointer; } button:hover { background: #0056b3; } .result-item { background-color: #f2f2f2; margin-bottom: 10px; padding: 10px; border-radius: 5px; display: flex; align-items: center; justify-content: space-between; } .copy-button { background: #007bff; color: #fff; border: none; padding: 5px 10px; border-radius: 4px; cursor: pointer; } .copy-button:hover { background: #0056b3; } .image-container { margin-bottom: 20px; } @media screen and (max-width: 768px) { body, .container, .input-group { padding: 10px; } } .hidden { display: none; } </style> </head> <body> <div class="container"> <div class="input-group"> <input type="text" id="inputInput" placeholder="Enter a input (e.g., Facebook Ads)"> <button id="generateButton">Generate Titles</button> </div> <div id="imageContainer" class="image-container"> <img src="https://ai.superseotools.net/" alt="Getting Started" style="max-width: 100%;"> </div> <ul id="titleList"></ul> </div> <script> document.addEventListener('DOMContentLoaded', function() { const generateButton = document.getElementById('generateButton'); const titleList = document.getElementById('titleList'); const inputInput = document.getElementById('inputInput'); const imageContainer = document.getElementById('imageContainer'); generateButton.addEventListener('click', function() { const input = inputInput.value; if (!input) { alert('Please enter a input.'); return; } imageContainer.innerHTML = '<img src="https://ai.superseotools.net" alt="Loading" style="max-width: 20%;">'; // Replace 'https://ai.superseotools.net' with your loading GIF // Clear existing titles and show the loading GIF titleList.innerHTML = ''; imageContainer.classList.remove('hidden'); fetch('https://ai.superseotools.net/wp-admin/admin-ajax.php', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: 'action=custom_tool_run&input=' + encodeURIComponent(input) }) .then(response => response.json()) .then(jsonResponse => { titleList.innerHTML = ''; if (jsonResponse.success) { const titles = jsonResponse.data[0].titles; titles.forEach(title => { let listItem = document.createElement('li'); listItem.className = 'result-item'; listItem.innerHTML = `<span>${title}</span> <button class="copy-button" onclick="copyToClipboard('${title}')">Copy</button>`; titleList.appendChild(listItem); }); imageContainer.classList.add('hidden'); // Hide the image container } else { console.error('Failed to fetch titles'); imageContainer.innerHTML = '<img src="https://ai.superseotools.net" alt="Error" style="max-width: 100%;">' + '<p>Oops! Something went wrong. Please try again.</p>'; } }) .catch(error => { console.error('Error:', error); imageContainer.innerHTML = '<img src="https://ai.superseotools.net" alt="Error" style="max-width: 100%;">' + '<p>Oops! Something went wrong. Please try again.</p>'; }); }); window.copyToClipboard = function(text) { var textArea = document.createElement("textarea"); textArea.value = text; textArea.style.top = "0"; textArea.style.left = "0"; textArea.style.position = "fixed"; document.body.appendChild(textArea); textArea.focus(); textArea.select(); try { var successful = document.execCommand('copy'); var msg = successful ? 'successful' : 'unsuccessful'; alert('Copying text was ' + msg); } catch (err) { alert('Unable to copy text'); console.error('Unable to copy', err); } document.body.removeChild(textArea); }; }); </script>
@badrsabra what do you see when you use the inspect function of the browser?
Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack
Same problem but No solution. Please help me with detailed solution
@ssadvisor I have updated the link to: http://quicktools.rf.gd.local/wp-admin/admin-ajax.php
@google-technicalsir @badrsabra I just did it again from scratch, and for it to work I only had to do 2 things:
- Generate my own Gemini Key and replace it
- Replace the URL with my own URL (I used a local host so I just changed it to the name of my local wp)
@google-technicalsir @badrsabra I tested both your URLs on reqbin and it gave me and error: "Could not resolve the host name. Error code: 1006"
So its probably something from your side, the function is working normally.
@badrsabra what do you think it should be? I'm asking you because I think it should be obvious. You also need to modify the http to https if that is what is expected.
Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack
I think it should be
fetch('https://superseotools.net/wp-admin/admin-ajax.php', {
method: 'POST',
headers: {
Or
fetch('https://www.superseotools.net/wp-admin/admin-ajax.php', {
method: 'POST',
headers: {
Or
fetch('https://superseotools.net/Public_html/wp-admin/admin-ajax.php', {
method: 'POST',
headers: {
Â
I don't know what is the right way i try all of that but get errors 404 when use the inspect function of the browser?
@badrsabra your server seems to be having issues at the moment but the answer will be related to how you access the 'wp-admin' login. This is simple enough for you to just try using the URL entry of your web browser.
Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack
@ssadvisor Error: TypeError: Cannot read properties of undefined (reading '0')
So your javascript is trying to read data that isn't available.
Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack