What is the possibility of reusing $ .change?
People have a problem. I need on the same page to use
Multiple changes in multiple selects. It works like this: First change: User chooses to select 1
The change runs and a get json search via Json in the URL and shows the result.
Second change: User chooses in select 2 (which is different from select 1) The change runs and m get json search via Json in the second URL and shows the result.
The problem is:
When I squeeze each change into separate pages, Perfect Wheel.
But when I scroll on the same page it does not work. What do I need to do so that all changes (I will have more than 2) will run on the same page.
Use of this form I have taken from the Jquery documentation
$( "select" ).change(function () {
var str = "";
$( "select option:selected" ).each(function() {
str += $(this).val() + " ";
});
console.log(str);
var url = "http://minhaurl.com/json?cidade="+str;
$.getJSON( url, function( data ) {
Json rodando perfeito.
});
})
.change();
I just repeat the function by changing the URL, STR, and select parameters.
There are other ways to achieve the same change effect. And what can I repeat on the same page?
NOTE: Each select has its ID . Each selector that receives the values has its ID .
Thanks, hugs
OBS 2: I do not intend to join them, They are separate.
Each has its URL, and has its answers.
To help [ link
I'm quite a beginner. So I do not know much.