I have an confliction problema, i need to use two versions of jquery at the same page, need the 1.7.2 is an function that i use to get from other page in php data from database according by a select change and i need the 1.8.2 to make my form validation, but i just can do one or other, if i try the two that just doesnt work.
I try to use jquery noconflict but i dont understand that so well, maybe i did that wrong or doesnt work.
the function that need 1.7.2:
function getmes(dropdown)
{
ano = dropdown.options[dropdown.selectedIndex].value;
$.ajax({
url: "ajax/mes.php",
dataType: "html",
type: 'GET',
async: true,
data: {
ano: ano
},
success: function (result) {
$("#mes").append(result.replace(/[\r\n]+(?=[^\r\n])/g,''));
}
});
}
and this is the function that need 1.8.2:
var dataForm = new VarienForm('form-id', true);
That's how you could accomplish this if absolutely necessary:
<script src="jquery.1.7.2.js"></script>
<script>
/* Here, you can use $ with your jQuery 1.7.2 code,
ie. use jQuery 1.7.2 as you normally would.*/
jQuery172 = jQuery.noConflict(true);
/*Now, you can no longer use $. Use jQuery172 with your jQuery 1.7.2
code here, ie. replacing "$" with "jQuery172" in your code.*/
</script>
<script src="jquery.1.8.2.js"></script>
<script>
/*Here, you can use $ again, but now with your jQuery 1.8.2 code,
ie. use jQuery 1.8.2 as you normally would.*/
jQuery182 = jQuery.noConflict();
/*Now, you can no longer use $. Here, you can use jQuery172 with your
jQuery 1.7.2 code and use jQuery182 with your jQuery 1.8.2 code.*/
</script>
However, I'd recommend refactoring your code in order to support the newer version. Loading two versions of jQuery means twice as much bandwidth on each page load. It's a burden for both your server (unless you're using a CDN) and the client. In addition, the browser will have to construct the jQuery object twice, which is certainly bad for performance, although it may not be noticeable on more recent computers.