Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Ajax Call Rate Topic   - - - - -

 
  • mohsin1631
  • Advanced Member
  • Members
  • Join Date: 18-May 22
  • 76 posts

Posted 20 July 2022 - 11:18 AM #1

hi i am sending ajax request like below

<a class="cm-ajax" href="index.php?dispatch=vendor_communication.threads&thread_id={$thread['thread_id']}&result_ids=chat_area_div">

and added a div like below

 <div class="chat-area" id="chat_area_div">
    {foreach $messages as $message} 
           <div class="chat-area-main">
                <div class="chat-msg">
                <div class="chat-msg-profile">
                 <img class="chat-msg-img" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/3364143/download+%2812%29.png" alt="" />
                 <div class="chat-msg-date">Message seen 3.16pm</div>
                </div>
                <div class="chat-msg-content">
                 <div class="chat-msg-text">{$message['message']}</div>
                </div>
            </div>
    {/foreach}
 <!--chat_area_div--></div>

here is the  controller code

if ($mode == 'threads')
{
    if (isset($_REQUEST['thread_id']) && isset($_REQUEST['is_ajax'])){
        $thread_id = $_REQUEST['thread_id'];
        $params = [
            'user_id'   => $auth['user_id'],
            'thread_id' => (int) $thread_id,
          ];
        $messages = fn_vendor_communication_get_thread_messages($params);
        // return $messages;
        Tygh::$app['ajax']->assign('messages', $messages);
        exit;
    }
   

}

The issue is that i am getting the response nothing is being displayed in the results_ids div.

and also results_id variable is not being sent with the ajax request url it is like

 

GET
http://pushi.local/index.php?dispatch=vendor_communication.threads&thread_id=34&is_ajax=1

 

 



 
  • mohsin1631
  • Advanced Member
  • Members
  • Join Date: 18-May 22
  • 76 posts

Posted 20 July 2022 - 11:36 AM #2

update:

i changed the ajax request according to documentation  added

data-ca-target-id="chat_area_div"

instead of adding result ids in the url but still its not working



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 22943 posts

Posted 20 July 2022 - 01:39 PM #3

Since you use the exit function, you should show some content before exit. E.g.

Tygh::$app['view']->display('path/to/template.tpl');

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 1210     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 4025     CS-Cart + YOUPI      USD 1459      Multi-Vendor Ultimate       USD 7500 (6000)


 
  • mlaking
  • Newbie
  • Trial users
  • Join Date: 22-Jul 22
  • 1 posts

Posted 22 July 2022 - 06:23 PM #4

@mohsin1631 Did you end up ever figuring this out? I have been struggling with trying to use Ajax/cm-submit with a checkbox to reload a div on the same page, without reloading the entire page. The documentation for CS-Cart is generally okay but the examples just aren't there and the few examples of CS-Cart handling things in a similar way in the original code base are irrelevant.

Cheers