I use the following code in my WordPress homepage template, and it works fine. However, when I try to use it in a page with a different path, it fails to find the file.
How do I dynamically establish my home path no matter what page I'm on? (I don't w开发者_运维问答ant to hardcode the full URL)
Works in mywordpress.com/
but not in mywordpress.com/page/
:
// Initiate asynchronous load of xml data:
jQuery.ajax({
type: "GET",
url: "wp-content/themes/mytheme/data.xml",
dataType: "xml",
success: parseDataXML
});
Maybe an absolute url?
// Initiate asynchronous load of xml data:
jQuery.ajax({
type: "GET",
url: "/wp-content/themes/mytheme/data.xml",
dataType: "xml",
success: parseDataXML
});
url: "/wp-content/themes/mytheme/data.xml",
the "/" do the trick
精彩评论