I am developing a joomla component. I added a drag and drop uploader with ajax. When a file is uploaded, a confirmation-mail should be sent. I get the right item of the database with $id = $app->input->getInt('id'); This works, But when the ajax call is done, the variable $id is set to null, so in the email the $customers->name is also null. Why is the complete model reloaded after the ajax-call?

I call the controller method:

Ajax Call

    cache: false,
    url: "index.php?option=com_customercenter&task=mailAfterUpload&tmpl=component",
    dataType: "json",
    formData: {"companyID":"companyID"},
    success: function(data) {
        for(var i=0;i<data.length;i++) { 


public function mailAfterUpload() {
    $model = $this->getModel();
    $response = $model->sendEmailAfterUpload();


public function sendEmailAfterUpload() {
    $customers = $this->getCustomercenterData();

    $mailer = JFactory::getMailer();
    $config = JFactory::getConfig();
    $sender = array( 
        $config->get( 'mailfrom' ),
        $config->get( 'fromname' ) 


    $user = JFactory::getUser();
    $recipient = $sender;


    $body = "Der Kunde: <b>" . $customers->name . "</b> hat neue Daten übermittelt<br>Ordner '" . $customers->upload_folder . "' checken" ;
    $subject = $customers->name . " hat neue Daten übermittelt";
    $mailer->Encoding = 'base64';

    $send = $mailer->Send();
    if ( $send !== true ) {
        echo 'Error sending email: ' . $send->__toString();
    } else {
        echo 'Mail sent';

Model sql-query

$app = JFactory::getApplication('site');
$id = $app->input->getInt('id');

1 Answer 1


By default, each http request is independent. You have to send all parameters again in each call.

Alternatively, if your client can keep session cookies, then you can store server-side variables in user session to keep an state between http requests.

$session = JFactory::getSession();
$session->set('myId', $myId);
$session = JFactory::getSession();
$myId = $session->get('myId');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.