Jump to content

Creating 2D Array from AJAX response


nano

Recommended Posts

Hello All,

 

I am currently stuck on a problem and haven't got a clue what to search, I've looked at most articles related to 2D arrays and AJAX. Sorry if this is in the wrong section of the forum, it related to JQuery, AJAX but mainly JavaScript 2D arrays.

 

I am using JQuery and want to create an array with error codes and messages.

 

Here is sample XML:

 

<resources>
    <resource name="errorCode1">Error Message One</resource>
    <resource name="errorCode2">Error Message Two</resource>
</resources>

 

Here is my current AJAX call:

 

$.ajax({
    type: "GET",
    url: "/resource.xml",
    dataType: "xml",
    success: function(xml) {
        $(xml).find('resource').each(function(){
            errorCode = $(this).attr('name');
            errorMsg = $(this).text();
        
        });
    }
});

 

What I am trying to do, somehow, is create an array that stores all error codes and error messages.

 

I then hope to pull back respective errors when searching for particular error codes.

 

Any help is greatly appreciated.

 

Cheers Guys.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.