jQuery: Function gives... Nothing?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Thew
    New Member
    • Aug 2010
    • 69

    jQuery: Function gives... Nothing?

    Code:
    <!DOCTYPE html>
    <html>
    	<head>
    		<title>Example</title>
    		<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
    		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
    		<script type="text/javascript">
    			(function($){
    				$.fn.awnlapi = function(apikey, type, image, xhtml = false, alt) {
    					if(xhtml == false){
    						var endtag = '>';
    					}
    					else
    					{
    						var endtag = '/>';
    					}
    					
    					$(fn).html('<img src="http://api.mywebsite.com/api.php?apikey='+ apikey +'&type='+ type +'&image='+ image +'" alt="'+ alt +'"'+ endtag);
    				}
    			}).jQuery;
    			
    			$().ready(function() {  
    				$('#image').awnlapi('893c5f6119f901f94b3ce67816f77f88127aff353b1a48d2f0f5c9c70a0f571589b84d04', 'gif', '1', false, 'This is alt!'); 
    			}
    	</head>
    	<body>
    		<div id="image"></div>
    	</body>
    </html>
    So i have my API, that uses $_GET variables to load an image. The only problem is that it returns nothing. No errors, no warnings, no images...

    What is wrong?

    Greetings
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    What is wrong?
    your function declaration. JS does not support default values. see also the Error Console.

    Comment

    • Thew
      New Member
      • Aug 2010
      • 69

      #3
      Removed the
      Code:
       = false
      ... But error console was empty.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        that is what a fix is supposed to do.

        Comment

        • Thew
          New Member
          • Aug 2010
          • 69

          #5
          But it still doesn't show anything. So...

          Comment

          Working...