Creating Ajax Call Using Jquery – Sugar CRM

Below is the code for jquery
You can write this code in your view.list.php or view.edit.php or view.detail.php
This ajax call will be occur in every 1 minute and show the message Hello in Popupbox
getStaticAdditionalDetails function is used to open popup as the popup of additional details from listview is opened.

 $javascript = <<<EOQ
       
  setInterval(function(){
    jQuery.ajax({
        url: "index.php?module=Cases&entryPoint=CaseNotify&passdate=$passdate",
        type: "POST",
        data: 'id=$id_string',
        success: function(data)
        {   
            var oData = data; 
            if(oData)
            {
             SUGAR.util.getStaticAdditionalDetails('#edit-$ArrayofIds[0]',oData,'Case Notification',false);
            }
        },
        error: function(msg)
        {
            alert("Case Notification Error");
        }
    });
},60000);

EOQ;
        echo $javascript;

Below is the code for custom/include/MVC/Controller/entry_point_registry.php
This file is entry point file for case module.

$entry_point_registry['CaseNotify'] = array('file' => 'custom/modules/Cases/CaseNotify.php', 'auth' => false);

Below is the code for custom/modules/Cases/CaseNotify.php
You can make logic as per you requirements

$message="Hello";
echo $message;
die;
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s