1

I am new to magento, and i am trying to make a simple ajax call in it

jQuery.ajax({
      url: url,
      dataType: 'json',
      type : 'post',
      data: data,
      async: true,
      success: function(data){
            //alert(data.status + ": " + data.message);
            if(data.status == 'SUCCESS'){
                jQuery('.loadingOverlay').hide();
                location.reload();
            }
      }
});

after response i need to reload the page to see the changes done by ajax call. Are there any other ways and how to implement them. Can anyone help.

  • What errors are you getting in this code ? – Anil Suthar May 20 '16 at 9:17
1

You are using jQuery... you can do that of course, but you have to make sure jQuery is properly implemented. Magento 1 uses Prototype by default, which means an Ajax Call might look about like this:

new Ajax.Request(url, {
        parameters: params,
        onSuccess: function(transport) {
            try {
                console.log(transport.responseText);

            } catch(e) {
                alert(e.message);
            }
        }.bind(this)
    });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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