uploading a file! can i prevent the page from being refreshed?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Amzul
    New Member
    • Oct 2007
    • 130

    uploading a file! can i prevent the page from being refreshed?

    hello all
    is it possible to upload a file without refreshing the page?

    snippt anyone?
    an idea?

    thanks
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Amzul.

    To do this, you'll need to use an iframe.

    Comment

    • Amzul
      New Member
      • Oct 2007
      • 130

      #3
      thanks man
      that nice..... useing ajax for uploading

      cant wait to try it out

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        Heya, Amzul.

        Let us know if it gives you any trouble :)

        Comment

        • Amzul
          New Member
          • Oct 2007
          • 130

          #5
          sorry for 2 in a row....

          can someone explian me the syntax of this :

          Code:
          AIM = {
          
              frame : function(c) {
          
                  var n = 'f' + Math.floor(Math.random() * 99999);
                  var d = document.createElement('DIV');
                  d.innerHTML = '<iframe style="display:none" src="about:blank" id="'+n+'" name="'+n+'" onload="AIM.loaded(\''+n+'\')"></iframe>';
                  document.body.appendChild(d);
          
                  var i = document.getElementById(n);
                  if (c && typeof(c.onComplete) == 'function') {
                      i.onComplete = c.onComplete;
                  }
          
                  return n;
              },
          i took it from here
          whats AIM a class?
          whats frame : means? is it like 'go to' like an anchor?
          why there is a ',' (comma) affter the end of the function?

          and in the main html
          Code:
          <form action="index.php" method="post" onsubmit="return AIM.submit(this, {'onStart' : startCallback, 'onComplete' : completeCallback})">
          the way i underrstand, it calls to a sequence of function. am i right?

          Comment

          • pbmods
            Recognized Expert Expert
            • Apr 2007
            • 5821

            #6
            Heya, Amzul.

            In this case, AIM is a generic object that contains an element named 'frame'. That element is a function object (see this article).

            The syntax for a JavaScript object (known as JSON) is:
            [code=javascript]
            variable =
            {
            'element name' : 'value',
            'name' : 'James',
            'age' : 32,
            'etc.' : function() { return 5; }
            };

            alert(variable. name); // 'James'
            alert(variable. age); // 32

            alert(variable['etc.']); // 'function() { return 5; }'
            alert(variable['etc.']()); // 5
            [/code]

            Comment

            Working...