我试图从本地服务器发送请求到youtube服务器bu铬控制台显示以下错误
Access-Control-Allow-Origin Code 不允许使用
http.open("POST", url, true);
http.setRequestHeader("Authorization", "AuthSub token=" + AccessToken);
http.setRequestHeader("GData-Version", 2);
http.setRequestHeader("X-GData-Key", "key=" + dev_key);
http.setRequestHeader("Content-Length", sendXML.length);
http.setRequestHeader("Content-Type", "application/atom+xml; charset=UTF-8");
http.onreadystatechange = function()
{
if(http.readyState == 4) {
alert(http.responseXML);
alert(http.responseText);
document.getElementById("response").innerHTML=http.getAllResponseHeaders();
}
}
http.send(sendXML);
Run Code Online (Sandbox Code Playgroud)
它将通过实现JSONP回调函数来完成.但我不知道如何实施它
plz指导我
我从YouTube获取JSON格式的数据,但它返回JSON为gdata.io.handleScriptLoaded({key:value});
如何key在PHP中访问,因为响应不是JSON对象
我想用一个单一的画布上绘制多个画布drawImage()方法,但它不能正常工作
守则
<html>
<head>
<script>
window.onload = function() {
var context1= document.getElementById("canvas1").getContext("2d");
var context2 = document.getElementById("canvas2").getContext("2d");
var context3 = document.getElementById("canvas3").getContext("2d");
context1.font = "20pt Calibri";
context1.fillStyle = "blue";
context1.fillText("Hello ", 50, 25);
context2.font = "20pt Calibri";
context2.fillStyle = "red";
context2.fillText("World!", 100, 25);
var imageObj = new Image();
imageObj.onload = function() {
context3.drawImage(context1.canvas, 50, 25);
context3.drawImage(context2.canvas, 100, 25);
};
};
</script>
</head>
<body>
<canvas id="canvas1" class="canvas" width="200" height="50"></canvas>
<canvas id="canvas2" class="canvas" width="200" height="50"></canvas>
<canvas id="canvas3" class="canvas" width="200" height="50"></canvas>
</body>
</html>? …Run Code Online (Sandbox Code Playgroud) 我正在使用Racspace服务器,其目录结构为
ROOT > web > Content
Run Code Online (Sandbox Code Playgroud)
所有文件都放在content文件夹中.但是当我放置.htaccess文件时,它会自动消失.和规则不起作用.而它在本地服务器上工作正常.htaccess文件中定义的规则是
RewriteEngine on
RewriteRule ^dashboard/([0-9]*)?$ dashboard.php?user_id=$1 [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
RewriteCond %{QUERY_STRING} ^(\w+)=(\w+)$
Run Code Online (Sandbox Code Playgroud) 我想发布一个形式poupup窗口.问题是,表单成功发布但它也在父窗口上发布.我想在弹出窗口中提交formonly
'<input type= button value ="Submit Form" onclick="adNetworkForm()" >
<script>
function adNetworkForm(){
targetUrl = "http://somesite.com"
var myForm = document.createElement('form');
myForm.method = 'post';
//myForm.action = targetUrl;
var inpt1 = document.createElement('input');
inpt1.setAttribute('name','a');
inpt1.setAttribute('type', 'hidden')
inpt1.value = "1";
var inpt2 = document.createElement('input');
inpt2.setAttribute('name','b');
inpt2.setAttribute('type', 'hidden')
inpt2.value = 2;
myForm.appendChild(inpt1);
myForm.appendChild(inpt2);
document.body.appendChild(myForm);
myForm.submit(popitup(targetUrl));
document.body.removeChild(myForm);
}
function popitup(url) {
newwindow=window.open(url,'name','height=600,width=500');
if (window.focus) {newwindow.focus()}
return false;
}
</script>?'
Run Code Online (Sandbox Code Playgroud)
我将JSON数据发送到解析它的控制器.
ROR代码
Class.where(challenge_id:challenge.id,song_id:song_hash['song_id']).first
Run Code Online (Sandbox Code Playgroud)
该错误是
can't convert String into Integer
Run Code Online (Sandbox Code Playgroud)
我甚至改变song_id:song_hash['song_id']到song_id:song_hash['song_id'].to_i,但没有奏效
该散列数据是
{"session_token"=>"Xt9toEzHI3bYXeJNkenyqg", "challenge"=>{"challenge_id"=>"15", "player_name"=>"usman", "guessed_songs"=>{"0"=>{"song_id"=>"10", "guessed"=>"YES"}, "1"=>{"song_id"=>"11", "guessed"=>"YES"}, "2"=>{"song_id"=>"12", "guessed"=>"YES"}, "3"=>{"song_id"=>"13", "guessed"=>"YES"}, "4"=>{"song_id"=>"15", "guessed"=>"YES"}}, "player_status"=>{"0"=>{"coins"=>"20", "points"=>"0", "player_name"=>"usman"}, "1"=>{"coins"=>"20", "points"=>"0", "player_name"=>"Usman"}}}}
Run Code Online (Sandbox Code Playgroud)
无法找到未转换为整数的内容