选择OnChange更改PHP变量


Selection OnChange change PHP Variable

你好,StackOverflow人员。

我需要你的帮助。我有这个代码:

<select name="type" onChange="idk?" class="form-control">
<option value="H">Week 51</option>
<option value="V">Week 52</option>
</select>

如果用户更改了我想更改的文件获取内容的周:s

$Week = "";
echo file_get_contents('http://rooster.farelcollege.nl/'.$Week.'/c/c00050.htm');

谢谢!

来自荷兰的问候=)

您可以向"file_get_contents"url发送Ajax请求。这就是我正在使用的,它运行良好:)

<select name="type" class="form-control">
    <option value="H">Week 51</option>
    <option value="V">Week 52</option>
</select>
$(document).ready(function() {
  $( ".form-control" ).change(function() {
    $.ajax({
        data: {
            // You are not sending any post variables right? Then leave this empty :-) otherwise use it as array 'var1': 'value', 'var2': 'value2' ...
        },
        url: 'http://rooster.farelcollege.nl/'+$(this).val()+'/c/c00050.htm',
        method: 'POST',
        success: function(msg) {
            alert(msg); // Optional, show text that was given by URL, can be removed
        }
    });
  });   
}); 

jquery.com/jquery.ajax