PHP and Ajax Help

need help with PHP and AJAX - not able to generate lead and display success message
$.ajax ( {
type:‘get’,
data : $("#frm6").serialize(),
success: function(data){
$(‘form#frm6’).slideUp(“fast”, function() {
document.getElementById(‘strSubmitStatus’).value = 1;
$("#mail-status").html(data);
$(’#loader-icon’).hide();
});
},
error: function(){}
});

<? if($_REQUEST['strSubmitStatus'] == 1 ) { // getting instance for intg data mgr $oCommonWebSiteIntgDataMgr = new CCommonWebSiteIntegrationDataMgr(0); // initialize request data $request_data = array(); // Get License detail view URL $request_data[_ID_XML_REQUEST_SERVICE ] = _ID_SERVICE_ADD_LEAD_INFO; $request_data[_ID_XML_REQUEST_INVOCATION_MODE ] = _ID_ADD_LEAD_INFO_INVOKED_FROM_ENQUIREY_FORM; $request_data[_ID_XML_REQUEST_CONTACT_NAME] = $_REQUEST['scntname']; $request_data[_ID_XML_REQUEST_EMAIL_ID] = $_REQUEST['semail']; $request_data[_ID_XML_REQUEST_PHONE_NUM] = $_REQUEST['sphone']; $request_data[_ID_XML_REQUEST_OTHER_CITY] = $_REQUEST['city']; $request_data[_ID_XML_REQUEST_REMARKS] = $_REQUEST['remarks']; $request_data[_ID_XML_REQUEST_INTEREST_TYPE] = _ID_LEAD_TYPE_SALES; $request_data[_ID_XML_REQUEST_COMM_TYPE] = _ID_KNOWN_COMM_TYPE_INBOUND; // source id $request_data[_ID_XML_REQUEST_SOURCE] = (!isset($_REQUEST['strSourceID']) || empty($_REQUEST['strSourceID'])) ? 0 : $_REQUEST['strSourceID']; // campaign id $request_data[_ID_XML_REQUEST_LEAD_CAMPAIGN_ID] = (!isset($_REQUEST['strCampaignID']) || empty($_REQUEST['strCampaignID'])) ? 0 : $_REQUEST['strCampaignID']; // set the interest id $interest_id = array(); // case : based on product type if( is_array( $_REQUEST['int1'] ) ) { // loop thru product array foreach( $_REQUEST['int1'] as $key => $value ) { switch($value) { case 'Tally.ERP 9': switch($_REQUEST['rbu']) { case 'Buy': $interest_id[] = 1; break; case 'Upgrade': $interest_id[] = 3; break; case 'Rent': $interest_id[] = 5; break; } break; case 'Shoper 9': $interest_id[] = 7; break; } } } else $interest_id[] = 1; // interest id $request_data[_ID_XML_REQUEST_INTEREST_ID] = $interest_id; // flag to check database entry failure $_REQUEST['DATABASE_ENTRY_FAILURE_FLAG'] = 0; // save lead Data if( ( $rc = $oCommonWebSiteIntgDataMgr->SaveLeadData($err_msg_array, $lead_id, $request_data) ) <= 0 ) { $_REQUEST['DATABASE_ENTRY_FAILURE_FLAG'] = 1; } if($_REQUEST['remarks'] == "Download the trial version" ){ $url = "CXRegisterforDemoMailerNew-2LIVE1.php?".http_build_query($_REQUEST)."&strLeadID=".$lead_id;} if($_REQUEST['remarks'] == "Buy Tally.ERP 9" ){ $url = "CXRegisterforDemoMailerNew-2LIVE2.php?".http_build_query($_REQUEST)."&strLeadID=".$lead_id;} header("Location:$url"); } ?>

Not sure if I can help, but, what error are you getting? Have you debugged it yet?
What line(s) of code is it failing at? We can’t duplicated it without your data, but, you should be able
to debug it. Just "die(“got-here…”); in a few places and see what the outputs of the PHP section gives
you and if that part is good. Display your $request_data[] array and your $_REQUEST[] array and then
die() to see if they are set up as you are expecting. You can display them using something like this:
[php]
echo “
request-data array:
”;
print_r($request-data);
echo “
$_REQUEST array:
”;
print_r($_REQUEST);
die (“
DONE!
”);
[/php]
Then, you can put that just before the interest array comment and see if you have well formed data going
into your AJAX routine. The Ajax code seems straight forward, but, not really sure of it.

I doubt that will help, but, I think we need more info to help you. Good luck!

Sponsor our Newsletter | Privacy Policy | Terms of Service