There are many problems here. Resolving one leads to another.
Uncaught ReferenceError: response is not defined
In your JavaScript code, you set the success
key to a function
function (data) { $("#result").html(response); }
response
is not defined. The callback has a function parameter ofdata
, notresponse
. This causes the error..html(…)
sets the HTML content of an element.data
would not be a reasonable variable to use since it is not HTML.- Returning something useful from the PHP code would provide no value without an element matching the query selector
#result
.
Therefore, delete the line $("#result").html(response);
.
Then your function would still not be called. Making a request to process.php
would declare the function but not call it. You need to actually call the function you declare, ButtonPubVideoHdp_InsertData()
, in your PHP.
This is not the right way to make AJAX requests with WordPress. Please follow the guidance at: