在此代码行中:
xmlhttp.open("GET","gethint.php?q="+str,true);
gethint.php?q="+str
的含义是什么,为什么这很重要?
在这里,
xmlhttp.open("GET","gethint.php?q="+str,true);
- 我们使用ajax,xmlhttp.open是XMLHttpRequest对象的一种方法。
- GET 是请求方法。
- gethint.php 是您要在其上发送请求的文件。
- q 是参数,其值是变量 str 的值。您正在将数据传递给gethint.php。您可以在gethint上接收q的值.php使用$_GET['q']。
- 第三个参数为真,用于异步。如果为 true,则将执行该请求之后的代码,如果为 false,则在请求完成之前不会执行该请求之后的代码。
意思是你得到参数q来gethint.php。当您只想获得结果而不重新加载时,这一点很重要。