locked
Java Script RRS feed

  • Question

  • Hi,

    I am using the following code. To debug that I have put alerts inside it but control is not passing through the function

    Inside it which is mycallback. What could be the reason ?

    function translate() {
    document
    .getElementById('trans').innerHTML="Translating... please wait";
    var text= document.getElementById('ori').value;
    window
    .mycallback = function(response) {
    document
    .getElementById('trans').innerHTML=response;
    }

    • Moved by Mike FengModerator Monday, July 2, 2012 3:06 AM JS (From:.NET Base Class Library)
    Thursday, June 28, 2012 7:46 AM

Answers

  • Hi HardikPopat ,

    How do you call  translate() ? It seems nothing wrong in  your code here , maybe you can give us more details , like  html code  in which called  this  function .

    In addition , I would like to give a code sample ,maybe you can have a try :

    <html> <head> <script type="text/javascript"> var languageFrom = "en"; var languageTo = "zh-CHS"; function translate(text) { document.getElementById('trans').innerHTML="Translating... please wait"; window.mycallback = function(response) { document.getElementById('trans').innerHTML=response; } var s = document.createElement("script"); s.src = "http://api.microsofttranslator.com/V2/Ajax.svc/Translate?oncomplete=mycallback&appId=6E27F3C1175EE277A80B2E5990008777796C99E5&from=" + languageFrom + "&to=" + languageTo + "&text=" + text; document.getElementsByTagName("head")[0].appendChild(s); } </script> </head> <body onload='translate("translator")' > <div id="trans"> </div> </body> </html>

    BTW , Our forums only support jscript related technologies , not Javascript . So , please use the ASP.NET forums  ( http://forums.asp.net/) for Javascript related questions.

    Thanks for your support and understanding !


    Lisa Zhu [MSFT]
    MSDN Community Support | Feedback to us



    Friday, June 29, 2012 5:55 AM
    Moderator

All replies

  • try clearing browser cache using developer tools (F12 key).  This is a .net baseclass library forum try posting in javascript forum

    Mark Answered, if it solves your question and Vote if you found it helpful.
    Rohit Arora

    Thursday, June 28, 2012 8:23 AM
  • Hi,

    I am using the following code. To debug that I have put alerts inside it but control is not passing through the function

    Inside it which is mycallback. What could be the reason ?

    function translate() {
    document
    .getElementById('trans').innerHTML="Translating... please wait";
    var text= document.getElementById('ori').value;
    window
    .mycallback = function(response) {
    document
    .getElementById('trans').innerHTML=response;
    }

    Thursday, June 28, 2012 8:48 AM
  • Hi HardikPopat ,

    How do you call  translate() ? It seems nothing wrong in  your code here , maybe you can give us more details , like  html code  in which called  this  function .

    In addition , I would like to give a code sample ,maybe you can have a try :

    <html> <head> <script type="text/javascript"> var languageFrom = "en"; var languageTo = "zh-CHS"; function translate(text) { document.getElementById('trans').innerHTML="Translating... please wait"; window.mycallback = function(response) { document.getElementById('trans').innerHTML=response; } var s = document.createElement("script"); s.src = "http://api.microsofttranslator.com/V2/Ajax.svc/Translate?oncomplete=mycallback&appId=6E27F3C1175EE277A80B2E5990008777796C99E5&from=" + languageFrom + "&to=" + languageTo + "&text=" + text; document.getElementsByTagName("head")[0].appendChild(s); } </script> </head> <body onload='translate("translator")' > <div id="trans"> </div> </body> </html>

    BTW , Our forums only support jscript related technologies , not Javascript . So , please use the ASP.NET forums  ( http://forums.asp.net/) for Javascript related questions.

    Thanks for your support and understanding !


    Lisa Zhu [MSFT]
    MSDN Community Support | Feedback to us



    Friday, June 29, 2012 5:55 AM
    Moderator