Buying Ajax Script Modification Needed

Discussion in 'Programming' started by mcmuney, Jan 25, 2013.

  1. #1
    I've found a free working script online that utilizes Ajax to reload a section (using DIV) of a page. The link to the script is here: http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm

    The script works fine when I use the Normal link:

    <a href="javascript:ajaxpage('test.htm', 'contentarea');">test</a>
    Code (markup):
    What I need is for this to work using a form and not a normal link. For example, I need it to work using a method, something like this:

    <input type="submit" name="Submit" value="Submit" onSubmit="javascript:ajaxpage('test.htm', 'contentarea')">
    Code (markup):
    But the above code doesn't work.

    The script link shows a few other examples, including the use within a form; however, it's only for a drop-down menu inside a form. I don't need multiple options, only one when the form is submitted.
     
    mcmuney, Jan 25, 2013 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    have you tried onclick?
    and at the end return false;

    
    [SIZE=13px][FONT=monospace]<input type="submit" name="Submit" value="Submit" onclick="javascript:ajaxpage('test.htm', 'contentarea'); return false;">[/FONT][/SIZE]
    [SIZE=13px][FONT=monospace]
    Code (markup):
    [/FONT][/SIZE]
     
    EricBruggema, Jan 25, 2013 IP
  3. tiamak

    tiamak Active Member

    Messages:
    81
    Likes Received:
    2
    Best Answers:
    3
    Trophy Points:
    58
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #3
    but this is just a part of solution. this way he will not submit form data...
     
    tiamak, Jan 25, 2013 IP
  4. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #4
    Yes i see, and you want the data to submit but as hidden? and then when submitting is done? you want to replace the content?

    Please describe in full what you need! :)
     
    EricBruggema, Jan 25, 2013 IP
  5. temp2

    temp2 Well-Known Member

    Messages:
    1,231
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    150
    Digital Goods:
    2
    As Seller:
    100% - 1
    As Buyer:
    100% - 0
    #5
    I really dont understand what you want? Check out my AJAX scripts?
     
    temp2, Jan 25, 2013 IP
  6. ArMouR

    ArMouR Well-Known Member

    Messages:
    161
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    130
    Digital Goods:
    1
    As Seller:
    100% - 2
    As Buyer:
    100% - 0
    #6
    Hi, I can try to help you and if I get through, you pay me? PM me the website details so I can have a look at it and explain what exactly you want done
     
    ArMouR, Jan 25, 2013 IP
  7. edduvs

    edduvs Well-Known Member

    Messages:
    394
    Likes Received:
    31
    Best Answers:
    3
    Trophy Points:
    160
    As Seller:
    100% - 2
    As Buyer:
    100% - 0
    #7

    You expect the form to perform its usuall action and the ajax to still do its job ? From what I can remember a normal form, without preventing the default method, redirects you do the attr('action') with the variables sent URIEncoded or as POST, depending on attr('method').


    The reason it is NOT working, is simply because "onSubmit" works for forms, not for input elements.
    1. Try this for example:
    
    <form (your attributes) onSubmit="javascript: ajaxpage('text','contentarea');">
    
    PHP:
    2. Or try my jQuery example:
    
    <!DOCTYPE html>
    <html>
       <head>
           <script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
           <script type="text/javascript">
               $(document).ready(function(){
                   $('#submit').click(function(e){
                       e.preventDefault();
                       $('#load').load('load_content.html');
                   })
               });
           </script>
       </head>
       <body>
           <input type="submit" id="submit" value="Change Content" />
           <div id="load"></div>
       </body>
    </html>
    
    PHP:
    Create a file named load_content.html (and enter there what you need to be displayed into <div id="load"></div>
     
    Last edited: Jan 26, 2013
    edduvs, Jan 26, 2013 IP
  8. alexpr07

    alexpr07 Active Member

    Messages:
    284
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    73
    As Seller:
    100% - 0
    As Buyer:
    100% - 1
    #8
    let me know if you still need the solution to this problem.
     
    alexpr07, Feb 2, 2013 IP