How to load Wordpress Post with Ajax onclick

前端 未结 3 1191
名媛妹妹
名媛妹妹 2020-12-09 00:38

I have spent hours reading and trying tutorials. I cant seem to find a solution that works and I know it should be pretty easy but I struggle with AJAX. :(

I want to

3条回答
  •  时光取名叫无心
    2020-12-09 01:06

    Barry's answer is correct about being able to load a partial page by adding a css selector expression to the end of the URL. However, there would need to be a space between the url and the selector like so:

    $("#tabs").load(post_url + " .tabcontent" );
    

    Otherwise the string passed to .load() would be http://example.com.tabscontent. But it should be http://example.com .tabscontent.

    Also, a word to the wise, using this method will stop jQuery from loading and executing any code inside

提交回复
热议问题