我有时会遇到这个问题,但仍然不知道是什么原因造成的.
我在页面中有这个脚本:
$(function(){
var value = "10";
});
Run Code Online (Sandbox Code Playgroud)
但是浏览器说"ReferenceError:value not defined".但是,如果我去浏览器控制台并输入任何一个
10
Run Code Online (Sandbox Code Playgroud)
要么
var value = "10";
Run Code Online (Sandbox Code Playgroud)
他们中的任何一个都可以返回10.我的脚本有什么问题?
编辑:只需摆脱"var"即可解决问题.
我一直在研究几个小时没有运气才能让它奏效.基本上我有一个cms,用户可以在其中放置soundcloud url,如" https://soundcloud.com/cade-turner/cade-turner-symphony-of-light ",然后该页面可以显示嵌入式iframe.我已经将api文档发送了一段时间,但找不到任何相关内容.这篇文章在这里谈过,但我只是不明白的答案,我查透过oEmbed和透过oEmbed参考,但找不到合适的例子.还有人提示吗?
编辑:感谢Jacob的回答,我终于设法通过使用ajax来实现.
var trackUrl = 'THE_URL';
var Client_ID = 'CLIENT_ID';//you have to register in soundcound developer first in order to get this id
$.get(//make an ajax request
'http://api.soundcloud.com/resolve.json?url=' + trackUrl + '&client_id=' + Client_ID,
function (result) {//returns json, we only need id in this case
$(".videowrapper, .exhibitions-image, iframe").replaceWith('<iframe width="100%" height="100%" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/' + result.id +'&color=ff6600&auto_play=false&show_artwork=true"></iframe>');//the iframe is copied from soundcloud embed codes
}
);
Run Code Online (Sandbox Code Playgroud) 我有这个
$example = "1234567"
$subtotal = number_format($example, 2, '.', '');
Run Code Online (Sandbox Code Playgroud)
$ subtotal的返回是"1234567.00"
如何修改$ subtotal的定义,使它像这样"1,234,567.00"
我为login.php页面所做的是,如果用户已登录,他将被重定向到first.php页面.
session_start();
if(isset($_SESSION['usr']) && isset($_SESSION['pswd'])){
header("Location: first.php");
}
Run Code Online (Sandbox Code Playgroud)
在所有其他页面中,如果用户尚未登录,则会将其重定向到login.php页面.
session_start();
if(!isset($_SESSION['usr']) || !isset($_SESSION['pswd'])){
header("Location: login.php");
}
Run Code Online (Sandbox Code Playgroud)
问题在于:有没有办法将用户重定向到他来自的地方?如果您在未登录时尝试访问second.php,则会立即将您重定向到login.php页面; 一旦你登录,你可以重定向回second.php而不是first.php吗?
我试过用$_SERVER['HTTP_REFERER'],但这个变量不包含任何东西; 它只包含一些东西,如果你在这里因为你点击了一个链接.
我正在使用Morris插件绘制折线图,但发现将两组数据组合在同一图中很困难。这是我的小提琴。它显示了我的第一个图表。
function formatDate(myDate){
var m_names = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
var d = new Date(myDate);
var curr_month = d.getMonth();
//var curr_year = d.getFullYear();
//return (m_names[curr_month] + "-" + curr_year);
return (m_names[curr_month]);
}
new Morris.Line({
element: 'financial-year-sales-graph',
data: [
{ month: '2013-07', sales: 52325 },
{ month: '2013-08', sales: 65432 },
{ month: '2013-09', sales: 52125 },
{ month: '2013-10', sales: 23265 },
{ month: '2013-11', sales: 25125 },
{ …Run Code Online (Sandbox Code Playgroud) javascript ×3
php ×3
comma ×1
definition ×1
http-referer ×1
jquery ×1
morris.js ×1
redirect ×1
session ×1
soundcloud ×1
var ×1
variables ×1