Site Notice

hello, world

Youdao translate

From Project-EPB Commons
Revision as of 21:37, 25 June 2020 by 机智的小鱼君 (talk | contribs) (Created page with "<html> <label for="origin">原文</label> <textarea id="origin" style="max-width: 100%; min-width: 100%; min-height: 4em"></textarea> <label>翻译</label> <pre id="translatio...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

<html> <label for="origin">原文</label> <textarea id="origin" style="max-width: 100%; min-width: 100%; min-height: 4em"></textarea> <label>翻译</label>


<button onclick="translate">翻 译</button>

<script>window.translate = function() { var text = $('#origon').val(); if (text === ) return; $.ajax({

 url: 'https://fanyi.youdao.com/openapi.do',
 data: {
   keyfrom: 'youdaoci',
   key: '694691143',
   type: 'data',
   doctype: 'jsonp',
   version: '1.1',
   q: text
 },
 dataType: 'jsonp'

}).done((data)=>{

 var translation = data.translation[0];
 $('#translation').text(translation);

}) }