What should be the return value from my AJAX procedure?

I need to return XML from ajax, but it is not working. I have a header in the main file (the one that makes the ajax call), which is as follows:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">




In this file I have this code:

function confirmarordendetrabajo(){
      if ( $("#inputcondiciones").attr("disabled") ) {
            alert ("Orden de trabajo ya fue generada");
      }
      else{
            $("#inputcondiciones").attr("disabled",true);
            $("#inputaccesorios").attr("disabled",true);
            $("#inputmantenimiento").attr("disabled",true);
            $("#saveVehicle").attr("disabled",true);
        $("#btngenerar").attr("disabled",true);
        var condiciones = escape($("#inputcondiciones").val());
        var accesorios = escape($("#inputaccesorios").val());
        var mantenimiento = escape($("#inputmantenimiento").val());
        var ncliente = $("#ncliente").val();
        var fecha = $("#xfecha").html();
        var noplaca = $("#element_1").val();
       
        $.ajax({
            type: "GET",
           url: "ln_taller.php",
            data: "funcion=3&ncliente="+ncliente+"&fecha="+fecha+"&nomanual=0&nocliente=0&marca=-1&tipoaparato=-1&modelo=-1&serie="+noplaca+"&condicion="+condiciones+"&accesorios="+accesorios+"&defecto="+mantenimiento+"&clientegarantia=0&garantia=0&fechacompra="+fecha+"&almacencompra=0&nfactura=0",
            dataType: "json",
            success:
                function(json){
                    alert ("Orden de Trabajo  fue generada satisfactoriamente");
                }

        });
      }
}


the code in BOLD, is where I call the ajax function.





the ajax file is: (ln_taller.php)

  class ln_ordendetrabajo{
      function guardar_boleta($ncliente,$fecha,$nomanual,$nocliente,$marca,$tipoaparato,$modelo,$serie,$condicion,$accesorios,$defecto,$clientegarantia,$garantia,$fechacompra,$almacencompra,$nfactura){
            require_once("sbd_conectar.php");


//this file contains the code needed to connect to MySQL.


            $con = new conectar;
            $sql = "select ifnull(max(norden),0)+1 as sig from ordenes_de_trabajo where id_empresa = " . $_SESSION["idempresaactual"];
            $conf = $con->ejecutar($sql);
            $row = mysql_fetch_array($conf);
            $norden = $row["sig"];

           $query = "insert into ordenes_de_trabajo(norden,id_empresa,id_sucursal,id_sucursal_actual,id_cliente,fecha,nomanual,nocliente,marca,tipoaparato,modelo,serie,condicion,accesorios,defecto,cliente_garantia,garantia,fecha_compra,almacen_compra,nfactura) values('".$norden."','".$_SESSION[idempresaactual]."','".$_SESSION[idsucursalactual]."','".$_SESSION["idsucursalactual"]."','".$ncliente."','".$fecha."','".$nomanual."','".$nocliente."','".$marca."','".$tipoaparato."','".$modelo."','".$serie."','".$condicion."','".$accesorios."','".$defecto."','".$clientegarantia."','".$garantia."','".$fechacompra."','".$almacencompra."','".$nfactura."')";
            $con->ejecutar($query);

            echo "{'success':'1','norden':'" . $norden . "'}";
      }
  }
  $a= new ln_ordendetrabajo;
  $funcion = $_GET[funcion];
  switch($funcion){
      case 3: $a->guardar_boleta($_GET[ncliente],$_GET[fecha],$_GET[nomanual],$_GET[nocliente],$_GET[marca],$_GET[tipoaparato],$_GET[modelo],$_GET[serie],$_GET[condicion],$_GET[accesorios],$_GET[defecto],$_GET[clientegarantia],$_GET[garantia],$_GET[fechacompra],$_GET[almacencompra],$_GET[nfactura]);
      break;
  }

The query in bold is executing fine, but the value of norden and of success, don't seem to be returning into the main file. Its supposed to show the alert. I have several functions that work fine, but in these I'm not using the header described in here.

The reason why I use these headers, is because it uses a good format for displaying.

Thanks, please ask me to clarify and I will respond as soon as possible.

Thanks experts.
aguisaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leakim971PluritechnicianCommented:
>I need to return XML from ajax,

So why dataType: "json", ?

put this in the front of your file

header('Content-Type: text/xml'); 
echo "<?xml version=\"1.0\"?><root>";

Open in new window


use a loop to read all the row and use an echo similar to this one :
echo "<tag>" . $row["field"] . "</tag>";

Open in new window


at the end, add the end tag of the root tag, for example :
echo "</root>";

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
aguisaAuthor Commented:
Sorry for the question, but what should I write instead of json?


thanks
0
leakim971PluritechnicianCommented:
0
aguisaAuthor Commented:
Thanks for all the support. Super useful.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.