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>
1
  • 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'. Commented Aug 1, 2011 at 8:01

2 Answers 2

2
.result(function(event, item) {
 $.ajax(
     {
         data: item,
         url: "insert url here",
     })
 });
Sign up to request clarification or add additional context in comments.

1 Comment

And most likely supply success function as well because we usually have to do something when call succeeds.
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'

Comments

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.