获取未定义的索引:来自ajax结果的url

index.php

<h1>Input the URL of the Video you want:</h1>
<input type="text" name="video" id="video">
<input type="submit" name="submit" value="Submit">
<div id="showvideo"></div>
<script>
    $(document).ready(function() {
        $('#video').change(function() {
            $.ajax({
                type: "GET",
                url: "youtube.php",
                date: {'url' : "$('#video').val()"},
                success: function(data){
                    $('#showvideo').html(data);
                }
            });
        });
    });
</script>

youtube.php

if($_GET['url']){
    $url = $_GET['url'];
    $video = new Youtube($url);
    echo $video->getVideo();
}

When pass in urls,I get

"Notice: Undefined index: url in /Applications/MAMP/htdocs/youtube.php on line 41".

I followed the instructions from this tutorial, it should be correct....

Its data not date in your ajax

date: {'url' : "$('#video').val()"},

change this to

data: {'url' : $("#video").val()},

Replace

date: {'url' : "$('#video').val()"},

with

data: {url : $('#video').val()},
-------^^^---^^^^^^^^^^^^^^^^^--

try this.

if(isset($_GET['url'])){
        $url = $_GET['url'];
        $video = new Youtube($url);
        echo $video->getVideo();
    }

you have a two mistakes.

  1. you have named the data attribute as date
  2. You have enclosed the jquery object inside a string causing the object not to expand.

data: {'url' : $('#video').val() }