Little adjustment,

            $.ajax({
                url: '{% url "xxxx" %}',
                data: {
                    'xxxxx': xxxx,
                },
                dataType: 'json',
                success: function (data) {
                    if (data.added_item) {
                        item = "<option value = '" + data.added_item + " '>"
 + data.added_item + "</option>";
                        $("#selectListID").append(item);
                    }
                }
            });



On Mon, May 25, 2020 at 7:56 PM Luqman Shofuleji <[email protected]>
wrote:

> Yes that's possible since you are using Ajax. It should be something like
> this:
>
>             $.ajax({
>                 url: '{% url "xxxx" %}',
>                 data: {
>                     'xxxxx': xxxx,
>                 },
>                 dataType: 'json',
>                 success: function (data) {
>                     if (data.added_item) {
>                         item = data.added_item
>                         $("#selectListID").append(item);
>
>                     }
>                 }
>             });
>
>
>
>
>
> On Mon, May 25, 2020, 4:12 PM Sherif Adigun <[email protected]>
> wrote:
>
>> I have a form which has a select field (your color). In front of the
>> select field, I have a button that produces a popup which allows users to
>> create new color before they submit. I am submitting that color form via
>> Ajax. After adding a new color to the database, the popup closes.
>> I want the newly added color to show in the select list without reloading
>> the page.
>>
>> Is this possible?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/9f176d90-93e3-40f8-b02f-4d27b6b55a75%40googlegroups.com
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHyB84pUQW48GvSL%2BHdQ3hzVRW9Bh4a6wtA0Tprz0bPkHXns_A%40mail.gmail.com.

Reply via email to