Keyup function doesn't work |
This script work perfectly on procedural, but in ci4, 'keyup' function doesn't work ?
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <script> $(document).ready(function() { $("#search").keyup(function() { $.ajax({ url: 'backend.php', type: 'post', data: {search: $(this).val()}, success: function(result) { $("#result").html(result); } }); }); }); </script> Is there somebody would like to help me please.. ?
CodeIgniter url is [ controller/method ].
Code: <script> What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
[quote pid="398183" dateline="1657349768"]
Thanks dude, its work, but something else happens. The #inputSearch called (showed up) twice ? [/quote] [quote pid="398183" dateline="1657349768"] I'm sorry but I need your solutions again ? [/quote]
Post your new code here so that we can see it.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
I'm sorry but I still use my own code, I just follow ur instructions to use ci url to controller/method
<form action="" method="post"> <div class="container mt-2"> <div class="row g-2"> <div class="input-group input-group-sm mb-2"> <input type="text" class="form-control" id="cari" name="cari" placeholder="search city or region.." maxlength="16" size="35%"> <button class="btn btn-success" type="button" name="search" id="search"">Submit</button> </div> <hr class="mb-0"> <div class="row" name="result" id="result"></div> <hr class="mb-0"> <small class="text-muted mt-0 pt-0">Made with ? <a href="/">CodeIgniter</a></small> </div> </div> </form> When I click submit, this whole form appears again below the result div between <hr class="mb-0">
Just to add to the above, it's not a good idea to do a round trip to the server on keydown, look into 'debouncing' if that is your intended behaviour.
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
|
Welcome Guest, Not a member yet? Register Sign In |