Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how would i remove term parameter from jquery autocomplete ajax URL

When going to search customer name, jQuery automatically appends cstmr-prfsnl-ajax-search.php?term=[search value] but I want to replace term with customer. please help me.

$("#ccpd_name").autocomplete({
  source: "cstmr-prfsnl-ajax-search.php",
  minLength: 1
});
like image 828
Subhankar Dutta Avatar asked Nov 24 '25 22:11

Subhankar Dutta


2 Answers

You can use like this :

$("#ccpd_name").autocomplete({
     source: function (request, response) {
        $.ajax({
             url: "cstmr-prfsnl-ajax-search.php",
             data: { customer: request.term },
             dataType: "json",
             success: response,
             error: function () {
                 response([]);
             }
         });
     });
});

cstmr-prfsnl-ajax-search.php?customer=[search value]

like image 186
helpdoc Avatar answered Nov 27 '25 11:11

helpdoc


you can also omit the data field like so:

$("#ccpd_name").autocomplete({
 source: function (request, response) {
    $.ajax({
         url: "cstmr-prfsnl-ajax-search.php?customer=" + request.term,
         dataType: "json",
         success: response,
         error: function () {
             response([]);
         }
     });
 });

});

like image 27
mahmoudafer Avatar answered Nov 27 '25 11:11

mahmoudafer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!