0

I am new to jQuery and Ajax but I understand some simple things. However my question is what I need to add to my existing code to submit the value of the selected value of the autocomplete script I use?

Thank you.

$("#s").autocomplete("rpc.php", {
    width: 250,
    selectFirst: false,
    minChars: 3,
    scroll:true,
    matchContains: true,
    scrollHeight: 250
}).result(function(event, item) {
     $.ajax({
        // what to send here?

            })
});

<form method="get" action=".php">
<input type="text" name="s" id="s" class="inputsearch">
<input id="searchform" type="submit">
</form>
Robert Koritnik
  • 103,639
  • 52
  • 277
  • 404
EnexoOnoma
  • 8,454
  • 18
  • 94
  • 179
  • Why don't you make your code easier? Seperate the code to submit the form and autocomplete. It makes your code easier to understand and to maintance. So you can use the form event 'onSubmit'. – Reporter Aug 01 '11 at 08:01

2 Answers2

2
.result(function(event, item) {
 $.ajax(
     {
         data: item,
         url: "insert url here",
     })
 });
Richard Dalton
  • 35,513
  • 6
  • 73
  • 91
0

jQuery AJAX form submission not working shows a good example to submit a form with ajax. You have only to change the value 'post' to 'get'

Community
  • 1
  • 1
Reporter
  • 3,897
  • 5
  • 33
  • 47