AJAX Hashing Submit Form

Discussion in 'JavaScript' started by YungKris15, Nov 9, 2012.

  1. #1
    I'm pretty sure it has to do with my core.js file with the ajax hashing url. But I'm trying to submit a form, but it's not submitting like I want it to. This is the core.js file:

     // call init
        $(init);
     
    
        function init() {
            ajax_page_handler();
            page_load($(window.location).attr("hash")); // goto first page if #! is available
        }
    
        function page_load($href) {
            if($href != undefined && $href.substring(0, 2) == '#/') {
                // replace body the #content with loaded html
                $('#content').load($href.substring(2), function () {
                    $('#content').hide().fadeIn('slow');
                });
            }
        }
    
        function ajax_page_handler() {
            $(window).bind('hashchange', function () {
                $href = $(window.location).attr("hash");
                page_load($href);
            });
    
            // this allow you to reload by clicking the same link
            $('a[href^="#/"]').live('click', function() {
                $curhref = $(window.location).attr("hash");
                $href = $(this).attr('href');
                if($curhref == $href) {
                    page_load($href);
                }
            });
        }
    
    Code (markup):
    The live viewing is over at www.krissales.com. The form is here: http://www.krissales.com/#/media/5.Testing-1

    Hit the link "Post Comment", then you'll type info in, then hit comment, but it just refreshes, but doesn't submit it.

    The steps I've taken to solve it was in the comment file, in the form action field, I inserted the tag `name="#comment"` simply because that's the name of my div that I'm submitting to.

    But apparently it's not working. Do you guys have a clue as to what it is that I'm doing wrong? thanks for your help in advance!

     <script type="text/javascript">
            tinyMCE.init({
                mode : "textareas",
                theme : "simple"
            });
        </script>
        <form action="" name="#comment" method="POST">
    
            Name:
            <br />
            <input type="text" name="name" class="userpass"/>
            <br /><br />
            Comment:
            <br />
            <textarea id="elm1" name="comment" rows="7" cols="30" style="width: 500px;"> 
            </textarea>
            <br />
            <input type="submit" name="submit" value="Comment" class="button" />
            <input type="reset" name="submit" value="Reset" class="button" />
    	
        </form>
    HTML:
     
    YungKris15, Nov 9, 2012 IP
  2. YungKris15

    YungKris15 Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    ayoooooooooooooooooooo
     
    YungKris15, Nov 10, 2012 IP
  3. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #3
    What file are you submitting to? form action="" says "to nothing".
     
    Rukbat, Nov 22, 2012 IP
  4. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #4
    Much less having a hash in it means don't submit it anywhere... Really not even sure what you're trying to do with that, though I suspect it's a nasty case of javascript for nothing... or at the very least javascript with zero fallbacks if the JS is blocked or unavailable. Almost looks like another case of using AJAX to replicate frameset behavior out of the whackjob "pageloads are evil" paranoia.
     
    deathshadow, Nov 26, 2012 IP