没有问题的解析错误

发布于 2024-10-29 02:41:40 字数 865 浏览 3 评论 0原文

我正在使用 Dashcode 制作一个移动网站来帮助我创建更好的 UI,但问题是我的代码上出现了一个奇怪的解析错误,没有任何问题......这是代码:

function get_currency(from, to) {
    var XMLHttp;  // Create the Ajax handler
    XMLHttp = new XMLHttpRequest();
    var url = "http://download.finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=" + from + to + "=X";

    XMLHttp.open("GET", url, true);
    XMLHttp.onreadystatechange = function() {
        if(XMLHttp.readyState == 4) {
            /* Once the server has completed its tasks display the result */
            var response = XMLHttp.responseText;
            var parsed_reply = response.split(',');

            document.getElementById('txtAmount').value = parsed_reply[1];
    }
    XMLHttp.send(null);
}

function btConvert_Click(event)
{
    get_currency("BRL", "USD");
}

发生错误(根据调试器)在第 209 行(代码的最后一行),这是我给出的这段代码的结尾。怎么了?

I'm making a mobile site using Dashcode to help me creating better UIs, but the problem is that I'm getting a strange Parse Error on my code, where nothing is wrong... This is the code:

function get_currency(from, to) {
    var XMLHttp;  // Create the Ajax handler
    XMLHttp = new XMLHttpRequest();
    var url = "http://download.finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=" + from + to + "=X";

    XMLHttp.open("GET", url, true);
    XMLHttp.onreadystatechange = function() {
        if(XMLHttp.readyState == 4) {
            /* Once the server has completed its tasks display the result */
            var response = XMLHttp.responseText;
            var parsed_reply = response.split(',');

            document.getElementById('txtAmount').value = parsed_reply[1];
    }
    XMLHttp.send(null);
}

function btConvert_Click(event)
{
    get_currency("BRL", "USD");
}

The error is occurring(According to the debugger) at the line 209(the last line of the code), which is the } a the end of this code that I gave. What's wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

软糖 2024-11-05 02:41:40

您缺少 onreadstatechange 处理程序的结束 } ,导致解析器在脚本末尾呕吐。考虑到缩进,它是 if(XMLHttp.readyState...) 检查的结束 }

You're missing a closing } for your onreadstatechange handler, causing the parser to puke at the end of the script. Given the indentation, it's the closing } for the if(XMLHttp.readyState...) check

陌路黄昏 2024-11-05 02:41:40

您缺少 }

根据您的间距,您尚未关闭 {

if(XMLHttp.readyState == 4) {

You're missing a }

Based on your spacing, you haven't closed the { from

if(XMLHttp.readyState == 4) {
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文