我正在开发一个原型到 jquery 项目。我需要将此函数底部的原型 ajax 请求转换为等效的 jquery。
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);
}
上述函数由以下函数调用:
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});
}
}
如果需要更多信息,请告诉我。任何帮助将不胜感激。