[英]Can I send Data to Controller after AJAX Success in PHP Codeigniter?
I want to send "data" to the controller that came from controller to success of ajax and its a different controller function then the first one. 我想向控制器发送“数据”,该数据是从控制器到成功的ajax及其与第一个控制器不同的控制器功能。
$.ajax({
url :'<?= base_url('Content/get_thumb') ?>', // Controller URL
type : 'POST',
data : formData,
async : false,
cache : false,
contentType : false,
processData : false,
success : function(data) {
$('#video_thumb').show();
$('#thumb_image').html('<img src="' + data + '" style="margin-top:57px;" /> ');
}
});
Yes you can, just after success function you can run another function that will send data back to your controller. 是的,您可以,在成功函数之后,您可以运行另一个函数,该函数会将数据发送回控制器。
$.ajax({
url :'Controller URL', // Controller URL
type : 'POST',
data : formData,
async : false,
cache : false,
contentType : false,
processData : false,
success : function(data) {
$('#video_thumb').show();
$('#thumb_image').html('<img src="' + data + '" style="margin-top:57px;" /> ');
function_name(data); //run another function to send data.
}
});
The function to run on sucess 成功运行的功能
<script type="text/javascript">
function function_name(DataToSend) {
$.ajax({
url :'<?= base_url('Content/get_thumb') ?>', // Controller URL
type : 'POST',
data : DataToSend,
success : function(response) {
//Do what needs to be done
}
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.