Link to home
Start Free TrialLog in
Avatar of brihol44
brihol44

asked on

$.Ajax success data.value parse

Hello,

I'm trying to return the value in the success (data) part of my $ajax call. I've looked through Google but what I'm looking for is a coded solution below. I don't think it's that complex from similar examples I've seen. I just can't seem to get mine working.

When I add alert(data); I get...

<wddxPacket version='1.0'><header/><data><string>1</string></data></wddxPacket>


but I would like to be able to run 2 different functions if <string> eq "1" or "". Is that possible?
 	$.ajax({
		type: "POST",
		url: "app/func_main.cfc?method=login",
               data: data,
		cache: false,
		success: function (data) {

			alert(data);

                      if (data.string == 1) {
                           function1();
                     } else {
                          function2();
                     }

 		},
 		error: function (xhr, ajaxOptions, thrownError) {
        alert(xhr.status);
        alert(thrownError);
      	}

	});

Open in new window

SOLUTION
Avatar of Robert Schutt
Robert Schutt
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of brihol44
brihol44

ASKER

Thanks for the help everybody! I tried them all but  leakim971's solution was the only one I got to work. Maybe I missed something on the others but it's exactly what I needed. Thanks!