如果响应:1则window.parent
我正在使用此脚本将注释插入数据库:
var http = createObject();
var nocache = 0;
function insert() {
document.getElementById('insert_response').innerHTML = "To Sek .. "
var fID= encodeURI(document.getElementById('fID').value);
var kommentar= encodeURI(document.getElementById('kommentar').value);
nocache = Math.random();
http.open('get', 'insert.php?fID='+fID+'&kommentar=' +kommentar+'&nocache = '+nocache);
http.onreadystatechange = insertReply;
http.send(null);
}
function insertReply() {
if(http.readyState == 4){
var response = http.responseText;
document.getElementById('insert_response').innerHTML = ''+response;
}
}
现在它 innerHTML
输出来自 insert.php
的响应文本。
但是在 insert.php
中,我在 PHP 中设置了一些“限制”,例如如果为空,如果双重发布等。 因此我不能放入:
window.parent.showMessage("Video Is OK");
//after
if (http.readystate == 4)..
所以我想对此脚本执行另一个函数,该函数检查 如果 div
框 #box
包含 1
,那么:
window.parent.showMessage("Video Is OK");
我该怎么做?
谢谢
I am using this script to insert comment to the database:
var http = createObject();
var nocache = 0;
function insert() {
document.getElementById('insert_response').innerHTML = "To Sek .. "
var fID= encodeURI(document.getElementById('fID').value);
var kommentar= encodeURI(document.getElementById('kommentar').value);
nocache = Math.random();
http.open('get', 'insert.php?fID='+fID+'&kommentar=' +kommentar+'&nocache = '+nocache);
http.onreadystatechange = insertReply;
http.send(null);
}
function insertReply() {
if(http.readyState == 4){
var response = http.responseText;
document.getElementById('insert_response').innerHTML = ''+response;
}
}
Right now it innerHTML
out the response text, that comes from insert.php
.
But inside insert.php
, I have setted up some "restrictions" in PHP like if empty, if double post etc. etc.
I can therefore not place in:
window.parent.showMessage("Video Is OK");
//after
if (http.readystate == 4)..
So I would like to do another function to this script, that checks
If the div
box #box
is containing 1
, then:
window.parent.showMessage("Video Is OK");
How can I do that?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否将任何错误传递给用户(例如,重复帖子、空帖子、太长的帖子)?如果是,并且成功后没有传递任何内容,您可以检查响应的长度,如果长度为零,则显示“视频正常”消息:
Are you passing any errors back to the user (e.g. on double posts, empty posts, too long posts)? If you are, and you don't pass anything back on success you could check the length of the response and show your "Video IS OK" message if the length is zero: