AJAX Form Button with PHP

1 day ago 2
ARTICLE AD BOX

The problem is that your

<span class="spinner"><i class="icon-spin icon-refresh" id="spinner"></i></span> Update

in the HTML does not really help you exactly evaluating it. To have an easy solution it makes sense to wrap an HTML element around it, like a span:

<span class="spinner"><i class="icon-spin icon-refresh" id="spinner"></i></span> <span class="update-text">Update</span>

and then, in submitForm2 you can do this:

function submitForm2() { let form = $("#globalAdminUpdateDetails-form"); let textElement = form.querySelector(".update-text"); var data = form.serialize(); $.ajax({ type : 'POST', url : 'response.php?action=globalAdminUpdateDetails', data : data, beforeSend: function(){ $("#error").fadeOut(); textElement.innerText = "updating..."; }, success : function(response){ if($.trim(response) === "1"){ console.log('dddd'); textElement.innerText = 'Details Updated'; } if($.trim(response) === "2"){ console.log('dddd'); textElement.innerText = 'Account blocked...'; } else { $("#error").fadeIn(1000, function(){ $("#error").html(response).show(); }); } } }); return false; }

Via wrapping an HTML element around the text you intend to change, it will be easy to change the inner text.

Mister Jojo's user avatar

Mister Jojo

23k6 gold badges28 silver badges46 bronze badges

Lajos Arpad's user avatar

2 Comments

Thank you for the support

2026-02-21T15:05:18.543Z+00:00

Happy to help! Let me know if you encounter a blocker while applying it.

2026-02-21T15:07:02.443Z+00:00

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.

Read Entire Article