我的 JavaScript 代码有什么问题?
我正在创建一个简单的测试器页面来测试我网站中的一些其他功能。我无法让它运行。我做错了什么?
<p>
<a href="#" id="addItem">Add item to cart</a>
</p>
<script>
$('#addItem').click(funtion(){ /* Expected '(' or ',' */
$.post('http://localhost:1969/AddToCart',
'SystemCodeId=WB&SystemKey1=123456&SystemKey2=123ABC&Cost=25.01&TransactionType=1&Description=This is a test',
function (data) {
document.location.replace('http://localhost:1969/');
});
}); /* Expected expressions */
</script>
Visual Studio 一直认为存在语法错误。我不怀疑,但我不知道问题出在哪里。这些评论是 Visual Studio 报告的错误。
Firebug 也不会识别该脚本(不会显示在脚本选项卡中)。所以我知道某个地方出了问题。
注意:我使用的是 HTML5。
I am creating a simple tester page to test some other functions within my website. I can't get it to run. What am I doing wrong?
<p>
<a href="#" id="addItem">Add item to cart</a>
</p>
<script>
$('#addItem').click(funtion(){ /* Expected '(' or ',' */
$.post('http://localhost:1969/AddToCart',
'SystemCodeId=WB&SystemKey1=123456&SystemKey2=123ABC&Cost=25.01&TransactionType=1&Description=This is a test',
function (data) {
document.location.replace('http://localhost:1969/');
});
}); /* Expected expressions */
</script>
Visual Studio keeps thinking there is a syntax error. I don't doubt it, but I can't figure out where the problem is. The comments are the errors that visual studio is reporting.
Firebug won't recognize the script either (doesn't show in the scripts tab). So I know there is a problem some where.
Note: I am using HTML5.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
函数
->第 5 行中的function
。还要转到站点的根目录,我将使用window.location = window.location.host
funtion
->function
in line 5. also to go to the root of your site i would usewindow.location = window.location.host