0

I have form:

<form id="search_user" name="search_user" method="post" action="<?php echo base_url();?>index.php/controller/function">
    <input type="submit" name="submit" id="submit" value="Submit Search" />
</form>
<script type="text/javascript" src="<?php echo base_url(); ?>js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>js/content1.js"></script>

here is my jquery;

$(':submit').submit(function () {
    var linkme = $(this);
    var url = linkme.attr("href");
    $(".content").load(url);

    return false;
});

When I press the button submit nothing happens. Please need your advice

7
  • Select the form element. $('#search_user').submit() Commented Feb 3, 2013 at 10:09
  • 1
    /jquery-1.3.2.min.js seriously ? (':submit') re... can't you upgrade & look at the latest jquery ways to bind events (delegating with .on( )? Commented Feb 3, 2013 at 10:12
  • @mikakun: I don't think upgrading jQuery is going to fix this issue. If changing the selector and the use of the correct form attribute (action) is fixing it then there is no need to upgrade jQuery just for the sake of it. Even if the elements are injected dynamically it is still possible to bind without on with delegation by placing the bindings into the right place. Though I do agree that if starting something new it's always nice to be able to start with the latest jQuery version. Commented Feb 3, 2013 at 10:30
  • @FrançoisWahl yeah & instead of upgrading jquery & your code "for the sake" of it you can also put in your jq1.3 site : "best viewed with firefox 3.6 & ie6" just in case some crazy internet explorer users are using 8 or 9 or 10 which are part of the reason jquery get upgrades as a matter of fact Commented Feb 3, 2013 at 10:46
  • 1
    Thanks guys I upgraded it to i.9 Commented Feb 3, 2013 at 11:18

1 Answer 1

1

You have used an incorrect selector :submit.

You could subscribe to the submit event of the form using its id and then use the action of this form to send an AJAX request:

$('#search_user').submit(function() {
    var url = this.action;
    $(".content").load(url); 
    return false; 
});
Sign up to request clarification or add additional context in comments.

1 Comment

when i try this its the same. when i click submit button nothing happens.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.