我有一些 jQuery post 代码,当我尝试运行它时,它会抛出未找到的错误。我正在尝试将其作为我的 WordPress 插件的一部分来运行,我知道这些文件位于同一目录中,但拼写正确。我尝试直接从 url 访问该文件并将该 url 添加到插件中,但随后收到错误 500。
根据我所做的研究,我认为我必须做一些事情才能在我的插件中添加这个文件,我认为这与它不在 WordPress 框架中有关,但我找不到任何解决我的问题的方法.
jQuery.post("getResults.php", {id:id} , function(data)
{
jQuery("select#kDate").removeAttr("disabled");
jQuery("select#kDate").html(data);
})
.success(function() { alert("second success"); })
.error(function(xhr, status, detail) { alert("error ("+status+") : " + detail); })
});
如有任何帮助,我们将不胜感激。
最佳答案
此代码通过使用文件的完整 url 来工作,如果您收到错误 500 内部服务器错误,请尝试更改您的权限,就像对我有用的那样。此代码适用于 wordpress。
jQuery.post("<?php echo plugins_url("/race-results/getResults.php"); ?>", {id:id} , function(data)
{
jQuery("select#kDate").removeAttr("disabled");
jQuery("select#kDate").html(data);
})
.success(function() { alert("success"); })
.error(function(xhr, status, detail) { alert("error ("+status+") : " + detail); })
});
关于WordPress 插件中的 jquery.post,目录问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14076928/