Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/395.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 用Coffeescript编写Ajax函数_Javascript_Jquery_Ajax_Coffeescript - Fatal编程技术网

Javascript 用Coffeescript编写Ajax函数

Javascript 用Coffeescript编写Ajax函数,javascript,jquery,ajax,coffeescript,Javascript,Jquery,Ajax,Coffeescript,小提琴- 今天我决定学习咖啡脚本,做一些函数,处理事件等等 然而今天我遇到了一个错误,上面写着“保留字‘函数’”,我还没有找到解决方法 原件: $(function () { function download_to_textbox(url, el) { $.get(url, null, function (data) { el.val(data); }, "text"); } download_to_textbox

小提琴-

今天我决定学习咖啡脚本,做一些函数,处理事件等等

然而今天我遇到了一个错误,上面写着“保留字‘函数’”,我还没有找到解决方法

原件:

$(function () {
    function download_to_textbox(url, el) {
        $.get(url, null, function (data) {
            el.val(data);
        }, "text");
    }
    download_to_textbox("http://code.jquery.com/jquery-latest.min.js", $("textarea"));
});
我的译文:

(($) ->
  function download_to_textbox(url, el) {
    $.get(url, null, (data) ->
      el.val(data);
      }, "text");
  }
  download_to_textbox("http://code.jquery.com/jquery-latest.min.js", $("textarea"));

  $("textarea").click ->
  $(this).select();
) jQuery

CS中没有
函数
关键字。
$ ->
    download_to_textbox = (url, el) ->
        $.get url, null, ((data) ->
            el.val data
            return
        ), 'text'

    download_to_textbox 'http://code.jquery.com/jquery-latest.min.js', $ 'textarea'
    $("textarea").click ->
        $(this).select()