0

Below i code that i am using

var $j = jQuery.noConflict();


$j(document).ready(function(){
    $j( "#stone_theme" ).change(function() {
            new Ajax.Request("http://localhost/infoz/test.php", {
                method: 'Post',
                parameters: {"parameter_name":"value"},
                onComplete: function(transport) {
                    alert(transport.responseText);
                }
            });
    });
});

but i had to include jquery for it is there any way to do this with out calling jquery ??..

1 Answer 1

1

Firstly you're very close already as you're not using jQuery's ajax functions. You've (correctly) used Prototype's ajax objects.

So now what you need to do is remove the jQuery dependency by adding click handler from Prototype.js (the js lib that ships with Magento).

To do that you want to

document.observe('dom:loaded', function(){

    $('stone_theme').observe('change',function(e){
        new Ajax.Request("http://localhost/infoz/test.php", {
            method: 'Post',
            parameters: {"parameter_name":"value"},
            onComplete: function(transport) {
                alert(transport.responseText);
            }
        });
    });


});

Note that the $ function for Prototype.js is essentially shorthand for document.getElementById - equivalent to the jQuery selector $('#stone_theme');

4
  • $('stone_theme').observe('change',function(e){ or $('#stone_theme').observe('change',function(e){ Nov 22, 2014 at 19:38
  • without the # sign
    – philwinkle
    Nov 22, 2014 at 19:44
  • thanks its working how can i get selected value of stone_theme dropdown i tried e.val but it give undefined value Nov 22, 2014 at 19:57
  • e.target.value should do it
    – philwinkle
    Nov 22, 2014 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.