0

I'm working on a protoype to jquery project. I need to convert this prototype ajax request at the bottom of this function to the jquery equivalent.

function formSubmit(url, options) { 
    $('#productform').action = url;
    var defaultOptions = {timeout: 300000, onSuccess : updateCallback, onFailure: failure, evalScripts: true};
    for (i in options) {defaultOptions[i] = options[i]}
    $('#productform').request(defaultOptions);
}

The above function is called by the following one:

function updateMain() {
    $('#Product_introduction').val(tinyMCE.get('Product_introduction').getContent());
    var string = $('#Product_introduction').val().replace(/\n/g,'');
    string = string.replace(/<script.*<\/script>/ig,'');
    string = string.replace(/<[^>]*>/ig, '');
    if(string.length > 110){
        ajax.displayMessage(t('Introduction is too long. It could be only 110 characters long. Please edit it.'), false);
    }
    if( $('#productId').val() == '' ) {
        formSubmit('/' + getControllerName() + '/create', {onSuccess: createCallback, onFailure: failureCallback});
    } else {
        formSubmit(getUpdateUrl('update'), {onSuccess: updateMainCallback, onFailure: failureCallback});
    }
}

If more information is need let me know. Any help will be greatly appreciated.

Circinus
  • 59
  • 1
  • 2
  • 8
  • Did you mean that you have to replace `$('#productform').request(defaultOptions);` code with jQuery equivalent? – Anusha Sep 24 '13 at 10:09
  • [converting prototype to jquery](http://stackoverflow.com/questions/572161/converting-from-prototype-to-jquery) might help you. – Anusha Sep 24 '13 at 10:12
  • Yes, that's the line that needs converting. Thanks I'll check out the link. – Circinus Sep 24 '13 at 10:37

0 Answers0