jQuery with ajax and JSON not returning fields

jQuery with ajax and JSON not returning fields

I have a PHP program that has a jQuery on a page to run a function and return fields if record is found.
I cheecked to make sure it has the:
java script for:

 <script type="text/javascript" src="/websmart/v8.9/javascript/jquery.min.js"></script>

 

and the javascript to run the funtion:


<script>

$(document).ready(function()

{

          var select = $("#CCARDNO");

 

          select.blur(valccmsn);

  });

 

  function valccmsn() {

          $.ajax({

                          type: "POST",

                          url: "fmccpmtf.php",

                          data: {

                                  'task'  : 'valccmsn',

                                  'CCARDNO' : jQuery('#CCARDNO').val(),

                                  'EXPDATE' : jQuery('#EXPDATE').val(),

                                  'CVV2CVC' : jQuery('#CVV2CVC').val(),

                                  'CHNAME' : jQuery('#CHNAME').val(),

                                  'SFLAG' : jQuery('#SFLAG').val(),        

},

                          success: function(data){

                                  data = JSON.parse( data );

 

                                  $('#EXPDATE').val(data[0]);

                                  $('#CVV2CVC').val(data[1]);

                                  $('#CHNAME').val(data[2]);

                                   $('#SFLAG').val(data[3);

                           }

                  });

          }

</script>    


 and the proper HTML to receive the data:



          <tr>

            <td>Credit Card Number:</td>

            <td>

              <input id="CCARDNO" type="text" name="CCARDNO" size="25" maxlength="25" value="$CCARDNO" onblur="setStyleBlur(this.id);" onfocus="setStyleFocus(this.id);" />

            </td>

          </tr>

          <tr>

            <td>Expiration  Date:</td>

            <td>

              <input id="EXPDATE" type="text" name="EXPDATE" size="5" maxlength="5" value="$EXPDATE" onblur="setStyleBlur(this.id);" onfocus="setStyleFocus(this.id);" /></td>

          </tr>

          <tr>

            <td>CVV2/CVC Credit Card Security Code:</td>

            <td>

              <input id="CVV2CVC" type="text" name="CVV2CVC" size="5" maxlength="5" value="$CVV2CVC" onblur="setStyleBlur(this.id);" onfocus="setStyleFocus(this.id);" /></td>

          </tr>

          <tr>

            <td>Card Holder Name:</td>

            <td>

              <input id="CHNAME" type="text" name="CHNAME" size="25" maxlength="25" value="$CHNAME" onblur="setStyleBlur(this.id);" onfocus="setStyleFocus(this.id);" /></td>

          </tr>

          <tr>

            <td>Street Address:</td>

            <td>

              <input id="STRADR" type="text" name="STRADR" size="30" maxlength="30" value="$STRADR" onblur="setStyleBlur(this.id);" onfocus="setStyleFocus(this.id);" /></td>

          </tr>

          <tr>

            <td>Zip:</td>

            <td>

              <input id="ZIP" type="text" name="ZIP" size="5" maxlength="5" value="$ZIP" onblur="setStyleBlur(this.id);" onfocus="setStyleFocus(this.id);" /></td>

          </tr>

 

and the function to run the jQuery:

 

function valccmsn()

{

// Validate Transaction Code Return TABCDES from file TABCD

// Make all global variables available here

foreach($GLOBALS as $arraykey=>$arrayvalue)

{

if ($arraykey != "GLOBALS")

{

global $$arraykey;

}

}

 

 

// Get the key field values which identify the record 

$CCARDNO = xl_get_parameter('CCARDNO');

$EXPDATE = xl_get_parameter('EXPDATE');

$CVV2CVC = xl_get_parameter('CVV2CVC');

$CHNAME = xl_get_parameter('CHNAME');

$SFLAG = xl_get_parameter('SFLAG');

 

// Fetch the row for page

$sqlstr = 'SELECT MCCARDNO, MEXPDATE, MCVV2CVC, MCHNAME, MSFLAG FROM JMALIB/CCMSTF

 WHERE ' . ' CCMSTF.MCCARDNO = \'' . xl_encode($CCARDNO, 'db2_search') . "'";

 

if (!$result = db2_exec($db2conn, $sqlstr))

{

// do any add validation here        

 

// Add row to table:

$execsql = 'INSERT INTO JMALIB/CCMSTF (CCMSTF.MCCARDNO , CCMSTF.MEXPDATE, CCMSTF.MCVV2CVC, CCMSTF.MCHNAME, CCMSTF.MSFLAG) VALUES('

. "'" . xl_encode($MCCARDNO, 'db2_search') . "'" . ' , '

. "'" . xl_encode($MEXPDATE, 'db2_search') . "'" . ', '

. "'" . xl_encode($MCVV2CVC, 'db2_search') . "'" . ', '

. "'" . xl_encode($MCHNAME, 'db2_search') . "'" . ', '

. "'" . xl_encode($MSFLAG, 'db2_search') . "'" . ') with NC';

$result = db2_exec($db2conn, $execsql);                                                        

}

else

{

$row = db2_fetch_assoc($result);

 

if ($row)

{

$MEXPDATE = $row['MEXPDATE'];

$MCVV2CVC = $row['MCVV2CVC'];

$MCHNAME = $row['MCHNAME'];

$MSFLAG = $row['MSFLAG'];

$EXPDATE = $MEXPDATE;

$CVV2CVC = $MCVV2CVC;

$CHNAME = $MCHNAME;

$SFLAG = $MSFLAG;

echo("<span style=\"color: red\"><font font-family:\"Arial\" size=\"3\"><B>credit Card on File!</B></span>" . $CCARDNO);

array_push($sReturn, $MEXPDATE);

array_push($sReturn, $MCVV2CVC);

array_push($sReturn, $MCHNAME);

array_push($sReturn, $MSFLAG);

}

else

{

echo("<span style=\"color: red\"><font font-family:\"Arial\" size=\"3\"><B>credit Card Not on File!</B></span>" . $CCARDNO);

}

}                        

echo( json_encode( $sReturn ) );

db2_close($db2conn);

}

 

I can't tell if it is running the function or not.  I have compared it with other programs that work and can't find any errors?

can any  one tell me if you see any erros or what to use to debug this to see if function is running? 

James R. Martin
J. Martin Associates