我有一个简单的形式
<tr>
<td> <input type="text" name="qty[]" placeholder="qty"/> </td>
<td> <input type="text" name="price[]" placeholder="price"/> </td>
<td> <input type="text" name="total[]" placeholder="Total"/> </td>
</tr>
Run Code Online (Sandbox Code Playgroud)
我们可以有多行与上面相同.
我需要的是当用户输入qty或需要更新price行时total.
我尝试了什么
$('input[name=\'qty[]\']').on('change keyup', function(){
var qty = $(this).val();
var price = $(this).parent('tr').find('input[name=\'price[]\']').val();
});
Run Code Online (Sandbox Code Playgroud)
price 是 undefined
或者有更简单的方法吗?请检查小提琴
更新:
.parent(..)选择当前元素集中每个元素的直接父元素.第一个参数过滤此集合.input元素的直接父元素是td元素,而不是tr元素.
更新小提琴
我正在向我的PHP/Apache服务器发送Ajax请求.该请求包含一个Authorization标题,如下面的浏览器开发工具的屏幕截图所示:
在针对我的本地Apache服务器进行测试时,我可以使用AuthorizationPHP从头文件中访问apache_request_headers().但是,在我的生产服务器上(在共享Linux主机上),返回的数组中缺少标头apache_request_headers,如下所示:
array(10) {
["Cookie"] => string(31) "_ga=GA1.2.1071821587.1446317606"
["Accept-Language"] => string(14) "en-US,en;q=0.8"
["Accept-Encoding"] => string(19) "gzip, deflate, sdch"
["Referer"] => string(27) "http://goaunited.com/admin/"
["User-Agent"] => string(110) "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36"
["Accept"] => string(33) "application/json, text/plain, */*"
["Cache-Control"] => string(8) "no-cache"
["Pragma"] => string(8) "no-cache"
["Connection"] => string(5) "close"
["Host"] => string(13) "goaunited.com"
}
Run Code Online (Sandbox Code Playgroud)
为什么Authorization标题不包含在apache_request_headers()我的生产服务器上的响应中?什么可能导致它被省略?