https://bugzilla.wikimedia.org/show_bug.cgi?id=48384

       Web browser: ---
            Bug ID: 48384
           Summary: jquery $.ajax() call regression on some wikis
           Product: MediaWiki
           Version: 1.22-git
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: Unprioritized
         Component: JavaScript
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified
   Mobile Platform: ---

(problem appears on hewiki and arwiki, but not on enwiki or mw)

after upgrade to 1.22wmf3, jquery 1.8.3, a strange problem appears.

the issue materialize when using $.ajax() call to extract the raw content of a
page, using "action=raw".

after upgrade to 1.8.3, jquery returns with error. depending on the page being
read, it's typically "unexpected token".

my conclusion is that jquery decides that page content is XML, and tries to
parse it, causing an "unexpected token" exception.

a workaround is to pass "dataType" explicitly to ajax call. both "text" or
"html" solve the problem.

here is a code snippet that used to work on hewiki, but causes exception now.
adding "dataType:'text' " cures it.
'עמוד ראשי' is hewiki name of main page. in reality, this is not the page i am
trying to read, but it's a good and stable example.

8<------------------------------------------
$.ajax({
    url: mw.util.wikiScript(),
    data: {title: 'עמוד ראשי', action: 'raw'}, 
    success: function(){alert('success')},
    error: function(){alert('error')}
    }
);
8<-----------------------------------------

as mentioned, adding "dataType: 'text'" solves the problem.
this does not happen here or on enwiki, but it does on hewiki and arwiki. not
sure it has anything to do with rtl vs. ltr - my sample set is just too small.

for completeness, here is the workaround:
8<------------------------------------------
$.ajax({
    url: mw.util.wikiScript(),
    data: {title: 'עמוד ראשי', action: 'raw'}, 
    dataType: 'text',
    success: function(){alert('success')},
    error: function(){alert('error')}
    }
);
8<-----------------------------------------

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to