Non-ajax GET/POST using jQuery (plugin?)

前端 未结 7 1696
南旧
南旧 2020-12-04 10:11

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 br

7条回答
  •  我在风中等你
    2020-12-04 10:57

    It is not clear from the question if you have a random bunch of values you want to pass on the querystring or is it form values.

    For form values just use the .serialize function to construct the querystring.

    e.g

    var qString = $('#formid').serialize();
    document.location = 'someUrl' + '?' + serializedForm
    

    If you have a random bunch of values you can construct an object and use the .param utility method.

    e.g

     var params = { width:1680, height:1050 };
     var str = jQuery.param( params );
     console.log( str )
     // prints width=1680&height=1050
     // document.location = 'someUrl' + '?' + str
    

提交回复
热议问题