Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to implement ajax and jquery into html
    primarykey
    data
    text
    <p>I asked a question before on how to add show/hide function to a div and render it exactly when a link is clicked. (<a href="https://stackoverflow.com/questions/9325192/start-rendering-div-or-maybe-iframe-with-php-content-inside-after-clickin?answertab=votes">The original question</a>) I received an answer to use jquery and ajax together to do this. Here is the code I received:</p> <pre><code>function unhide(){ $('#id-of-showhide-div').css({'display','block'}); $.ajax({ url: 'http://api.microsofttranslator.com..', // your url to microsoft translator success: function(data) { $('#id-of-showhide-div').html(data); } }); } </code></pre> <p>Now since I'm new to this I don't know how to use this. This is the html I tried to make but it doesn't work:</p> <pre><code>&lt;script type="text/javascript"&gt; function unhide(){ $('#id-of-showhide-div').css({'display','block'}); $.ajax({ url: 'api.microsofttranslator.com/V2/Ajax.svc/Translate?appId=SOMETHING&amp;from=en&amp;to=de&amp;text=Hello', // your url to microsoft translator success: function(data) { $('#id-of-showhide-div').html(data); } }); } &lt;/script&gt; &lt;a href="javascript:unhide('a');"&gt;Show/Hide Value&lt;/a&gt; &lt;div id="a"&gt;javascript:unhide('a');&lt;/div&gt; </code></pre> <p>I the microsofttranslator link outputs some text. I want it to only load that url when someone clicks the Show/Hide value link. And it has to be loaded only once. I mean when someone clicks it, it is rendered and shown, when he clicks it again it gets hidden and when he clicks it once more it doesn't render it once more and shows it from the the first time he clicked it. By the way I have many divs on the page so every id needs to be unique.</p> <p>Sorry for the long question.</p> <p>Thanks</p> <p>PS: If the api is done on the client's side it won't be a problem too.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload