Update dropdown when pop-up window closes

Asked

Viewed 34 times

1

When filling a form I created shortcuts to add data to dropdowns list but when I close the window pop-up, refresh the entire page.

  • I’m using the following code:

    window.onunload = refreshParent; Function refreshParent() { window.opener.Location.Reload(); }

The problem when updating the whole page is, it clears the data you already entered. in the rest of the form however. How to do to just refresh on dropdown that we add data?

1 answer

1

I think there you are already talking about Ajax. An easy way to use Ajax is with jQuery

You can use:

$.ajax({

accepts: {

mycustomtype: 'application/x-some-custom-type'

},

// Instructions for how to deserialize a `mycustomtype`

converters: {

'text mycustomtype': function(result) {

// Do Stuff

return newresult;

}

},

// Expect a `mycustomtype` back from server

dataType: 'mycustomtype'

});

http://api.jquery.com/jquery.ajax/

  • Yes, it can be done through an Ajax request but how do I only update the dropdown, because in the background this request you placed is similar to what I did but what I did was in javascript.

  • So it depends on how you are getting the information to add in the dropdown. You can set a id for this dropdown and with the information added in it, for example, imagine that the field is a input and that we’re using jQuery, it would be something like this: $("seuDropdown").find("option").val( $("input").val()).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.