43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
$(document).on('click', '#ajax_form_submit', function(){
|
|
// $('#ajaxForm').ajaxSubmit({
|
|
// beforeSubmit: function(a,f,o) {
|
|
// o.dataType = 'script';
|
|
// if (o.dataType == 'script') {
|
|
// o.url = o.url.split('?'); // split on GET params
|
|
// if (o.url[0].substr(-3) != '.js') o.url[0] += '.js'; // force rails to respond to respond to the request with :format = js
|
|
// o.url = o.url.join('?'); // join on GET params
|
|
// }
|
|
// },
|
|
// success: function(response,status,xhr){
|
|
// alert(response);
|
|
// alert(status);
|
|
// alert(xhr);
|
|
// },
|
|
// error:function(){
|
|
// alert("error");
|
|
// }
|
|
// });
|
|
|
|
|
|
var o = {
|
|
// dataType: 'script',
|
|
dataType: 'html',
|
|
url:$("#ajaxForm").attr("action"),
|
|
success: function(response,status,xhr){
|
|
alert(response);
|
|
eval(response);
|
|
|
|
},
|
|
error:function(){
|
|
alert("error");
|
|
}
|
|
}
|
|
|
|
if (o.dataType == 'script') {
|
|
o.url = o.url.split('?'); // split on GET params
|
|
if (o.url[0].substr(-3) != '.js') o.url[0] += '.js'; // force rails to respond to respond to the request with :format = js
|
|
o.url = o.url.join('?'); // join on GET params
|
|
}
|
|
$('#ajaxForm').ajaxSubmit(o);
|
|
|
|
}); |