在wordpress中自定义ajax请求 [英] Custom ajax requests in wordpress
问题描述
我的问题涉及到我应该从我的页面视图中创建一个我想要调用的ajax函数。
My question pertains to where I should create an ajax function that I'd like to call from my page view.
我在自定义上使用jQuery验证器应该检查输入的邮政编码对我的有效zipcodes数据库的表单。
I am using a jQuery validator on a custom form that should check the inputted zipcode against my database of valid zipcodes.
我只需要知道这个函数应该存在的位置。
I just need to know where this function should exist.
通常在使用非wordpress网站时我会d使用我的ajax函数创建一个PHP文件,并通过引用此页面的URL并传递一些参数来调用它们。
Normally when using a non wordpress site I'd create a PHP file with my ajax functions and call them by referencing the URL to this page and passing some parameters.
如何使用wordpress实现这一目标?我在哪里可以显式调用php文件并传递参数?
How can I achieve this with wordpress? Where can i explicitly call a php file and pass it arguments?
注意:我想像这样调用ajax函数:
Note: I'd like to call the ajax function like so:
$.post('http://mysite.com/ajax-functions.php?fxn=zipcodes',
{zipCode:00000},
function(response){
// do stuff
});
谢谢
推荐答案
事实证明你可以将函数挂钩到ajax函数中
Turns out you can hook a function into the ajax functions
http://www.1stwebdesigner.com/css/implement-ajax-wordpress-themes/
这篇关于在wordpress中自定义ajax请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!