jQuery - CodeSnippets

参考

marketplace.visualstudio.com

www.buildinsider.net

jqAjax2.snippet

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.6.0">
    <Header>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
      <Title>jqAjax2</Title>
      <Author>John Sheehan (@johnsheehan)</Author>
      <Description>Perform an asynchronous HTTP (Ajax) request.</Description>
      <HelpUrl>https://github.com/kspearrin/Visual-Studio-jQuery-Code-Snippets</HelpUrl>
      <Shortcut>jqAjax2</Shortcut>
    </Header>
    <Snippet>
      <Declarations>
        <Literal Editable="true">
          <ID>url</ID>
          <ToolTip>The URL for the request</ToolTip>
          <Default>/url</Default>
          <Function>
          </Function>
        </Literal>
        <Literal Editable="true">
          <ID>method</ID>
          <ToolTip>HTTP Method to use (GET, POST, etc.)</ToolTip>
          <Default>POST</Default>
          <Function>
          </Function>
        </Literal>
        <Literal Editable="true">
          <ID>data</ID>
          <ToolTip>Data to send (querystring)</ToolTip>
          <Default>name=John&amp;location=Boston</Default>
          <Function>
          </Function>
        </Literal>
        <Literal Editable="true">
          <ID>dataType</ID>
          <ToolTip>Options: xml|json|jsonp|text|html|script</ToolTip>
          <Default>json</Default>
          <Function>
          </Function>
        </Literal>
        <Literal Editable="true">
          <ID>url</ID>
          <ToolTip>URL to call</ToolTip>
          <Default>/url</Default>
          <Function>
          </Function>
        </Literal>
      </Declarations>
      <Code Language="javascript"><![CDATA[$$.ajax({
                    type: "POST",
                    url: "/url",
                    dataType: "json",
                    data: "name=John&location=Boston",
            }).done(function (data) {

            }).fail(function(data) {

            }).always(function(data) {

      });]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>