From 967a37adc4868fd4eb678475528d902a0864b44a Mon Sep 17 00:00:00 2001 From: ilvalle Date: Tue, 22 Jul 2014 10:22:48 +0200 Subject: [PATCH] online editor:potential fix for requests cancelled due to same origin policy --- applications/admin/static/js/ajax_editor.js | 14 +++----------- applications/admin/views/default/edit.html | 8 +++----- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/applications/admin/static/js/ajax_editor.js b/applications/admin/static/js/ajax_editor.js index 9e002397..54f74625 100644 --- a/applications/admin/static/js/ajax_editor.js +++ b/applications/admin/static/js/ajax_editor.js @@ -249,14 +249,7 @@ function keepalive(url) { } function load_file(url, lineno) { - $.ajax({ - type: "GET", - contentType: 'application/json', - cache: false, - dataType: 'json', - url: url, - timeout: 1000, - success: function (json) { + $.getJSON(url, function (json) { if(typeof (json['plain_html']) !== undefined) { if($('#' + json['id']).length === 0 || json['force'] === true) { // Create a tab and put the code in it @@ -271,11 +264,10 @@ function load_file(url, lineno) { } $("a[href='#" + json['id'] + "']").trigger('click', lineno); } - }, - error: function (x) { + }).fail(function() { on_error(); - } }); + return false; } function set_font(editor, incr) { diff --git a/applications/admin/views/default/edit.html b/applications/admin/views/default/edit.html index deb8dcbd..c2af8ced 100644 --- a/applications/admin/views/default/edit.html +++ b/applications/admin/views/default/edit.html @@ -199,11 +199,6 @@ $(document).on('click', 'a.font_button', function (e) { }); current_font_incr = (new_incr !== 0) ? current_font_incr + new_incr : 0; }); - -{{if len(request.args) > 1:}} - load_file('{{=URL(f='edit', args=request.args, vars=request.get_vars)}}', {{=request.vars.lineno or 1}}); -{{pass}} - {{block sectionclass}}edit{{end}} @@ -305,6 +300,9 @@ $(document).ready(function() { $('#files').css('left', '-'+ow+'px'); $.web2py.trap_form('url', 'form'); $('#form form').addClass('no_trap'); // Let to reuse the same form + {{if len(request.args) > 1:}} + load_file('{{=URL(f='edit', args=request.args, vars=request.get_vars)}}', {{=request.vars.lineno or 1}}); + {{pass}} });