I want to solve this problem as I am sending ajax request from on plugin page to another file verifyapi.php but it gives me error like below.
Fatal error: Uncaught Error: Call to undefined function get_option() in verifyapi.php
But when adding below line
require_once('../../../../../wp-config.php');
on top of verifyapi.php it works fine but I don't want it as WordPress don't allow you to add any WordPress core file in your function so is there any other way to do it.
Here is the js code of admin-ui.php page which sends data to verifyapi.php and then get a response back from it.
function savedata()
{
var keyflag=document.getElementById("key_box_flag").value;
if(keyflag=1)
{
var key=document.getElementById("key_box").value;
jQuery.ajax({
url:"<?php echo plugins_url( '/', __FILE__ ); ?>verifyapi.php",
type:"POST",
async:true,
data:{"key":key,
"save":1 },
success: function(data)
{
location.reload();
}
});
}
else {
}
}