2014-04-14 89 views
1

当我调用下面的代码段时,我得到空白内容而不是保存在代码段中的代码。有人能告诉我我错过了什么吗?如果我用“foobar”这样的字符串替换代码,当我调用代码片段时,字符串会显示出来。所以看来我错过了一些东西。Sublime Text 2 Snippet returned blank

<snippet> 
    <content> 
<![CDATA[ 

$.ajax({ 
  url: '/path/to/file', 
  type: 'POST', 
  dataType: 'xml/html/script/json/jsonp', 
  data: {param1: 'value1'}, 
  complete: function(xhr, textStatus) { 
    //called when complete 
  }, 
  success: function(data, textStatus, xhr) { 
    //called when successful 
  }, 
  error: function(xhr, textStatus, errorThrown) { 
    //called when there is an error 
  } 
}); 

]]> 
</content> 
<tabTrigger>ajax</tabTrigger> 
</snippet> 
+0

重复这个问题: http://stackoverflow.com/questions/13961566/new-to-sublime-cant-figure-out-snippets -with-javascript-in-them?rq = 1 您需要转义'$' – JaggsWaggert

回答

1

就逃不出你的jQuery呼叫

<snippet> 
    <content> 
<![CDATA[ 

\$.ajax({ 
    url: '/path/to/file', 
    type: 'POST', 
    dataType: 'xml/html/script/json/jsonp', 
    data: {param1: 'value1'}, 
    complete: function(xhr, textStatus) { 
    //called when complete 
    }, 
    success: function(data, textStatus, xhr) { 
    //called when successful 
    }, 
    error: function(xhr, textStatus, errorThrown) { 
    //called when there is an error 
    } 
}); 

]]> 
</content> 
<tabTrigger>ajax</tabTrigger> 
</snippet>