langziyang Posted October 31, 2014 Share Posted October 31, 2014 i create module,and i use jquery ajax function in the .tpl file. the ajax code like this: $("#submit_carrier_number").click(function () { var total_shipping = $("input[name='total_shipping']").val(); var id_order = $("input[name='id_order']").val(); var carrier_number = $("input[name='carrier_number']").val(); $.ajax({ url: baseUri + "modules/freightcollect/updatashipping.php", data: "total_shipping=" + total_shipping + "&id_order=" + id_order + "&carrier_number=" + carrier_number, dataType: 'json', success: function (json) { if (json.succ === true) { location.reload(); } else { alert(json.msg); } } }); }); and my updateshipping.php code like this: <?php require_once(dirname(__FILE__) . '/../../config/config.inc.php'); require_once(dirname(__FILE__) . '/../../init.php'); $module = new FreightCollect(); $valueback = array('succ' => TRUE, 'msg' => $module->l('this is my text')); echo json_encode($valueback); when use $module->l() function,the ajax can not execute location.reload() or alert(json.msg). if the php file change like $valueback = array('succ' => TRUE, 'msg' => 'this is my text'); echo json_encode($valueback); all can execute. how can i use it? Link to comment Share on other sites More sharing options...
Recommended Posts