jquery - sending an ajax GET with a javascript response format -
i trying following
$("select.languages").on("change", function(){ var lang = $(this).find("option:selected").text(); $.get(url: "/search", data: {"lang": lang}, datatype: 'script'); });
so every time language selected call /search
language , other answers make datatype "script"
but doesn't quite work. work
$.get( "/search.js",{"lang": lang} )
yet pollutes url since format explicit , doing using method requires me add pointless code
can implicitly set response format?
try instead:
$.ajax({ url: "/search", data: {"lang": lang}, datatype: 'script' });
the get shorthand method not accept parameters object this.
Comments
Post a Comment