ajax not working after form submit |
[eluser]TerryE[/eluser]
I have a ajax call on a input field to get the users id before the form is submitted. It works as long as the form is not submitted. the ajax call goes to index.php/login/test and the form gets submitted to index.php/login/validate_user. Not sure why this is happening.
[eluser]TerryE[/eluser]
Code: [removed]
[eluser]TerryE[/eluser]
Sorry about the messy code, but every time i try to post code it does not work.I did run firebug and the error i got after the form was submitted was 404 page not found and the ajax call is looking index.php/login/index.php/login/test
[eluser]CroNiX[/eluser]
That's very hard to follow with the formatting. The URL probably can probably be solved by adding a / before it, like '/index.php/login/test' so it starts from the site root instead of relative (appending to current url).
[eluser]TerryE[/eluser]
Code: $('#username').focusout(function() { by adding the var url fixed the problem
[eluser]CroNiX[/eluser]
Yes, but when you change to a different server you will have to manually update all of those urls. In my template head, I do: Code: <skript type="text/javascript">var base_url = "<?=base_url(); ?>";</skript> Code: var url = base_url + 'controller/method/etc'; So when you update your application and set the base_url, it changes in your js as well as the links in your app, assuming you used the URL helpers.
[eluser]jonez[/eluser]
Why define the URL at all? Pull it from the form that triggers the event. Code: <form id="myForm" action="<?=base_url( '/submit/path' )?>" data-user-validate="<?=base_url( '/validate/user/path' )?>" method="post"> Just realized you're validating the username not submitting the form, updated example. For that you can either use a relative path from the site root (everything except the domain) or set a data attribute on the form and read that as the URL (if you want to pass it through base_url).
[eluser]M Arfan[/eluser]
here is the complete solution http://www.learnipoint.com/forum/showthr...=10#post10 if you have any problem with codeigniter you can post on above link within 1 hour you will get your solution thanks |
Welcome Guest, Not a member yet? Register Sign In |