Solved

How to read ajax returned data

Posted on 2014-02-23
5
440 Views
Last Modified: 2014-02-25
I have ajax function that I'm called a stored procedure and returning data into an array, but when I loop through the array I'm getting undefined. But the data is getting retrieved when debugging the code. Below is attached file code, the array is a multidimenstional array but when I do for loop I should hit alert("Yes Admin") but the data is showing as an object. How to read the data and put my if condtions with in the for loop.
code-EE.txt
0
Comment
Question by:bujjigadu
  • 3
  • 2
5 Comments
 
LVL 54

Expert Comment

by:Julian Hansen
ID: 39881765
Two questions

1. What format is your data being returned in from your script
2. Can you post a sample of the data being returned.
0
 

Author Comment

by:bujjigadu
ID: 39882565
I'm attaching the sample data file here
datafile-EE.txt
0
 
LVL 54

Accepted Solution

by:
Julian Hansen earned 370 total points
ID: 39882736
So you are retuning your data as JSon - but you don't tell your ajax call that is what you are doing.

Try adding

   dataType: 'JSON'

To your AJAX call parameters.
0
 

Author Comment

by:bujjigadu
ID: 39885861
Good
0
 
LVL 54

Expert Comment

by:Julian Hansen
ID: 39886079
@bujjigadu, is there any particular reason you awarded a B for this question?

Default is an A unless there is a specific reason for it to be a B.

You can read more about grading guidelines here http://support.experts-exchange.com/customer/portal/articles/481419
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question