- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
在下面的例子中,如果值是数字,它工作正常。但如果它是字符串,则值显示为 0 W3 Schools Example
HTML:
<select name="users" onchange="showUser(this.value)">
<option value="">Select a person:</option>
<option value="abc-01">Peter Griffin</option>
<option value="aaac-02">Lois Griffin</option>
</select>
脚本:
function showUser(str) {
if (str == "") {
document.getElementById("txtHint").innerHTML = "";
return;
} else {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET","ajax2.php?q="+str,true);
xmlhttp.send();
}
}
PHP:
$q = intval($_GET['q']);
echo $q ;
我得到 0 作为值。需要帮助
最佳答案
您正试图在 php 中将 String 转换为 int,因为您的 htm 代码中有 String 值,并且您正试图在 php 代码中将这些值转换为 int,因此请相应地更正您的代码。
如果 html 是
<select name="users" onchange="showUser(this.value)">
<option value="">Select a person:</option>
<option value="abc-01">Peter Griffin</option>
<option value="aaac-02">Lois Griffin</option>
</select>
然后是 php 代码。
$q = $_GET['q'];
echo $q ;
关于javascript - 未获取 ajax-xmlhttp.open 中的字符串值 ("GET","xxx.php?q="+str,true);,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27450130/
来自this example的新手ajax问题: 在 xmlhttp.open() 和 xmlhttp.send() 之前如何分配 xmlhttp.responseText ? (如果我们需要demo
有两个progid。我见过两个都用过。 任何人都知道我什么时候应该使用一个,什么时候应该使用另一个? 最佳答案 你绝对不应该使用 Microsoft.XmlHttp。 来自 Microsoft XML
实际上我正在开发一个聊天框......但它不符合这个条件。 这是代码 function submitChat() { if (form1.users.value == "" || form1.me
网络服务器正在返回状态代码和描述以响应 XmlHttp 的请求。成分。来自服务器的实际状态响应开头为: HTTP/1.1 400 Not a valid http POST request 我可以在
我的问题是更多的搜索基础,但是如果我更改 readState 值意味着 4 以外的值会发生什么,如果我更改状态值 200 会发生什么以及为什么这里使用常量值或神奇数字 最佳答案 这不是神奇的数字。 您
我已阅读 the MSDN blog post关于它。 和 this question对我也没有太大帮助。 据我所知,检查 Microsoft.XmlHttp 就足够了。 你能确认一下吗 thisbu
我在我的页面上尝试使用 ajax。但它不起作用,因为 if (xmlhttp.readyState==4 && xmlhttp.status==200) 始终为 false。我已经提醒了 xmlhtt
我正在通过ajax发送电子邮件来联系php。 Php 脚本成功发送电子邮件,但 ajax xmlhttp.readyState 始终返回 2,即使 xmlhttp.status 为 200。 para
我希望这两个对象调用都指向 ActiveXObject。 但是为什么我们要传递两个不同的参数才能在 IE 中工作。 1. Msxml2.XMLHTTP 和 2. 微软.XMLHTTP 他们都一样吗?或
代码如下: url="http://www.csdn.net/" wstr=getHTTPPage(url) start=Newst
我正在编写一组 VBA 宏,其中使用 XMLHTTP 对象向服务器发送异步请求。我发送基本身份验证: XMLHttpReq.setRequestHeader "Authorization","Basi
我正在尝试使用 xmlhttp 和 VBA 抓取网站。 Url 有一个井号 (#) 符号,被 VBA 误解了...... 这与此处解释的问题相同: Error in XMLHTTP Get reque
我当前使用的 xmlhttp 函数正在将一个非常小的 int 传递到 php 文件,以便使用 GET 方法进行处理。 xmlhttp=GetXmlHttpObject(); if (x
我需要严格遵守我的xml文档中元素的顺序。如果我使用 XmlHttpContent 序列化程序来形成 xml 内容,字段将按字母顺序排序。 有没有办法明确指定 xml 中元素的顺序?或者还有其他方法可
我正在尝试使用 javascript 并阅读 from http://search.yahooapis.com/ WebSearchService /V1/webSearch?appid=YahooD
url太长就会提示没有权限,ie8不会,这应该跟浏览器有关的 其实有个问题你注意一下就是,改成POST 方式传就解决了 this.xmlHttp.open("POST", thi
我的 AJAX 不工作,我不知道为什么。我错过了什么?? ReferenceError: xmlhttp 未定义@ javascript.js:5 function insapts(pin){
我有一个从这个 url 获取表格的代码 https://www.reuters.com/companies/AAPL.OQ/financials/income-statement-annual 代码没
我正在尝试让 Excel 从搜索引擎中检索数据 (torrentz.eu/search?q=abc) 它应该获取第一个链接的信息并将其显示在 Excel 上: 单元格 A1:我的查询 单元格 A2:链
我正在尝试使用此代码抓取网站以提取姓名和联系人... Sub Test() Dim htmlDoc As Object Dim htmlDoc2 As Object Di
我是一名优秀的程序员,十分优秀!