2014-04-14 116 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>