0

Consider the following AJAX request:

$.ajax({
    url: 'http://www.minecraftwiki.net/api.php?action=query&meta=siteinfo&siprop=namespaces&format=json',
    dataType: 'json',
    async: false,
    success: function(siResponse) {
        for(var ns in siResponse.query.namespaces) {
            if(siResponse.query.namespaces[ns].id >= 0) {
                if(siResponse.query.namespaces[ns].id != namespaces.length) {
                    break;
                }
                if(siResponse.query.namespaces[ns].id === 0) {
                    namespaces[siResponse.query.namespaces[ns].id] = 'Main';
                } else {
                    namespaces[siResponse.query.namespaces[ns].id] = siResponse.query.namespaces[ns].&asterisk;;
                }
                movelog[siResponse.query.namespaces[ns].id] = 0;
                protectlog[siResponse.query.namespaces[ns].id] = 0;
            }
        }
    }
});

Here's the API response

Now, I could just use .canonical and rename the ids 4 and 5 from the default "Project" to "Minecraft Wiki", but I would like to use the "*": value instead. Is that possible, or is this just a bad wiki setting?

ThiefMaster
  • 310,957
  • 84
  • 592
  • 636
Kanegasi
  • 5
  • 3
  • 1
    You should really get rid of `async: false`. You don't need it. Really. Trust me. – ThiefMaster Jan 02 '13 at 23:12
  • I looked it up, because honestly I didn't know what that did. I just built off example ajax calls. json doesn't even support that lol. Thanks for the tip. – Kanegasi Jan 03 '13 at 03:01

2 Answers2

0

To the best of my knowledge: no, you cannot begin an id with an asterisk, number, or other special characters. See this post for more info.

Community
  • 1
  • 1
Nick Tomlin
  • 28,402
  • 11
  • 61
  • 90
0

You need to use foo['*'] to access the field instead of foo.* which would be a SyntaxError.

So in your case it would be siResponse.query.namespaces[ns]['*']

ThiefMaster
  • 310,957
  • 84
  • 592
  • 636