Support » Developing with WordPress » Fetch URL parameter

  • I have an URL

    I would like to fetch team value teamOne in functions.php like below.

    function get_data()
    	echo json_encode($_GET['team']);	
    add_action('wp_ajax_get_data', 'get_data'); 
    add_action('wp_ajax_nopriv_get_data', 'get_data'); 

    But it is not working.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz


    Try an URL query string like this:
    WP Ajax always requires an “action” parameter be passed.

    You’re trying to fetch data in an ajax callback so you must send an ajax GET request

    so instead of this

    use this

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Fetch URL parameter’ is closed to new replies.