admin管理员组文章数量:1399912
I'm fairly new to JavaScript and AJAX, but I'm trying to take an AJAX's requests' response text and split it into an array (the response text is ma separated). Here's the error I get:
Uncaught TypeError: object is not a function localhost:36
myrequest.onreadystatechange
Here's my code:
var currentpicid;
var currentcat;
var currentindex;
myrequest.onreadystatechange=function(){
if (myrequest.readyState==4 && myrequest.status==200){ //request successful
var infoarray = myrequest.responseText.split(',');
currentpicid = infoarray(0);
currentcat = "top";
currentindex = index;
document.getElementById("image").innerHTML=myrequest.responseText;
}
}
Can anyone help me? I have verified that my PHP page is just outputting a ma separated list of values. Thanks!
I'm fairly new to JavaScript and AJAX, but I'm trying to take an AJAX's requests' response text and split it into an array (the response text is ma separated). Here's the error I get:
Uncaught TypeError: object is not a function localhost:36
myrequest.onreadystatechange
Here's my code:
var currentpicid;
var currentcat;
var currentindex;
myrequest.onreadystatechange=function(){
if (myrequest.readyState==4 && myrequest.status==200){ //request successful
var infoarray = myrequest.responseText.split(',');
currentpicid = infoarray(0);
currentcat = "top";
currentindex = index;
document.getElementById("image").innerHTML=myrequest.responseText;
}
}
Can anyone help me? I have verified that my PHP page is just outputting a ma separated list of values. Thanks!
Share Improve this question asked Dec 7, 2012 at 4:04 DannyF247DannyF247 6384 gold badges15 silver badges35 bronze badges 1-
Getting this same error in ES6 for:
Array.prototype.filter(allChats, chat => chat['response'] != '')
– Kristopher Noronha Commented Jan 31, 2021 at 3:10
1 Answer
Reset to default 6Instead of:
currentpicid = infoarray(0);
you need:
currentpicid = infoarray[0];
The parentheses are for function calls. Use square brackets for array indexes.
本文标签: javascriptError quotobject is not a functionquot with arrayStack Overflow
版权声明:本文标题:javascript - Error "object is not a function" with array - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744167647a2593628.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论