gpt4 book ai didi

javascript - CS-Cart Ajax响应div

转载 作者:行者123 更新时间:2023-12-03 09:17:50 25 4
gpt4 key购买 nike

CS-Cart ajax 工作正常,我也收到响应,但如何在我的 View (checkout.tpl)文件上使用 html/js 响应。

Controller (前端):send_sms.php

use Tygh\Registry;
use Services_Twilio;
use Tygh\Ajax;

if ($_SERVER['REQUEST_METHOD'] == 'POST') {

if ($mode == 'send_sms') {

$status = 1;
$response = array(
'status' =>$status,
'data' =>'Hello World',
);

if($status == 1) {
fn_set_notification('N', fn_get_lang_var('success'), fn_get_lang_var('sms_sent'), true);
} else {
fn_set_notification('E', fn_get_lang_var('warning'), fn_get_lang_var('sms_failed'), true);

}

$val=json_encode($response);

Registry::get('ajax')->assign('result', $val);

}
exit;
}

查看 checkout.tpl (design/themes/responsive/templates/views/checkout/checkout.tpl)

<div id="result">
<!-- id="result" -->
<!-- result -->
</div>
<h2>Verify your number</h2>

<form class="cm-ajax" action="index.php" method="post" name="send_sms">


<input type="hidden" name="result_ids" value="result" />

<div class="form-control send_sms_block">
<input type="text" name="country_code" id="country_code" disabled value="+92"/>
<input type="text" name="carrier_code" id="carrier_code" disabled value="300"/>
<i class="ty-icon-down-micro open_cr"></i>
<input type="text" name="phone" id="phone"/>

<div class="carrier_list hidden">
<ul>
<li>301</li>
<li>302</li>
</ul>
</div>
</div>
<div class="clearfix"></div>
<input class="ty-btn ty-btn__big" id="send_sms" type="submit" value="Send Pin" name="dispatch[send_sms.send_sms]"/>
</form>

最佳答案

请尝试以下解决方案:

php 文件:

use Tygh\Registry;
use Services_Twilio;
use Tygh\Ajax;

if ($_SERVER['REQUEST_METHOD'] == 'POST') {

if ($mode == 'send_sms') {

$status = 1;
$response = array(
'status' =>$status,
'data' =>'Hello World',
);

if($status == 1) {
fn_set_notification('N', fn_get_lang_var('success'), fn_get_lang_var('sms_sent'), true);
} else {
fn_set_notification('E', fn_get_lang_var('warning'), fn_get_lang_var('sms_failed'), true);

}

$val=json_encode($response);

Registry::get('view')->assign('result', $val);
Registry::get('view')->display('views/path/to/tpl/file.tpl');
}
exit;
}

tpl 文件:

<div id="result">
{if $result}{$result}{/if}
<!--result--></div>

<h2>Verify your number</h2>

<form class="cm-ajax" action="index.php" method="post" name="send_sms">


<input type="hidden" name="result_ids" value="result" />

<div class="form-control send_sms_block">
<input type="text" name="country_code" id="country_code" disabled value="+92"/>
<input type="text" name="carrier_code" id="carrier_code" disabled value="300"/>
<i class="ty-icon-down-micro open_cr"></i>
<input type="text" name="phone" id="phone"/>

<div class="carrier_list hidden">
<ul>
<li>301</li>
<li>302</li>
</ul>
</div>
</div>
<div class="clearfix"></div>
<input class="ty-btn ty-btn__big" id="send_sms" type="submit" value="Send Pin" name="dispatch[send_sms.send_sms]"/>
</form>

关于javascript - CS-Cart Ajax响应div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31915361/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com