This is one of those situations where I feel like I'm missing a crucial keyword to find the answer on Google...
I have a bag of parameters and I want to make the browser navigate to a GET URL with the parameters. Being a jQuery user, I know that if I wanted to make an ajax request, I would simply do:
$.getJSON(url, params, fn_handle_result);
But sometimes I don't want to use ajax. I just want to submit the parameters and get a page back.
Now, I know I can loop the parameters and manually construct a GET URL. For POST, I can dynamically create a form, populate it with fields and submit. But I'm sure somebody has written a plugin that does this already. Or maybe I missed something and you can do it with core jQuery.
So, does anybody know of such a plugin?
EDIT: Basically, what I want is to write:
$.goTo(url, params);
And optionally
$.goTo(url, params, "POST");
jQuery Plugin seemed to work great until I tried it on IE8. I had to make this slight modification to get it to work on IE:
(function($) { $.extend({ getGo: function(url, params) { document.location = url + '?' + $.param(params); }, postGo: function(url, params) { var $form = $("<form>") .attr("method", "post") .attr("action", url); $.each(params, function(name, value) { $("<input type='hidden'>") .attr("name", name) .attr("value", value) .appendTo($form); }); $form.appendTo("body"); $form.submit(); } }); })(jQuery);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With