Question : How do I get a parent form value for jQuery.ajax post


Hi

I have the following script for an autocomplete modified from the example here:
http://theycallmemrjames.blogspot.com/2010/03/jquery-autocomplete-with-aspnet-mvc.html

In the second ajax call I need to get a record id from a hidden form field to post with the id from the selected autocomplete item, or I could get it from the url but where the id is the last folder value, e.g.:

http://web/edit/1234

I need to do something like

select: function (event, ui) {
                    $.ajax({
                        url: "/home/insert", type: "POST", data: { recordID: Request.Form["RecordID"], id: ui.item.id },

I'm very new to jQuery. Any help is appreciated.
Thanks
Andrew
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
<script type="text/javascript" language="javascript">
        $(function () {

            $("#name-list").autocomplete({
                source: function (request, response) {
                    $.ajax({
                        url: "/home/findnames", type: "POST", dataType: "json",
                        data: { searchText: request.term, maxResults: 10 },
                        success: function (data) {
                            response($.map(data, function (item) {
                                return { label: item.FullName, value: item.FullName, id: item.PersonId }
                            }))
                        }
                    })
                },
                select: function (event, ui) {
                    $.ajax({
                        url: "/home/insert", type: "POST", data: { id: ui.item.id },
                        success: function (data) { $("#display-list").html(data); }

                    })
                }
            });

        });
    </script>

Answer : How do I get a parent form value for jQuery.ajax post

Example here
Dim CancelChanges As DialogResult = MessageBox.Show("Your changes will be lost, are you sure?", "Cancel Changes", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
            If CancelChanges = Windows.Forms.DialogResult.No Then
                Exit Sub
            End If
Random Solutions  
 
programming4us programming4us