I am using a third party API. When the user is on a third party app and does some activity like messaging, the third party will send me a JSON request of activity to my CodeIgniter app endpoint.
I want to update the view of CodeIgniter with a notification that user sent some message etc.
I need some light that how to achieve this. Thanks
Use Ajax (Core or JQuery AJAX).. I prefer JQuery AJAX
// You can use a setInterval also, but im using button click to call api $(document).on('click', '.button', function(event) { event.preventDefault(); var url1 = BASE_URL+"controller/method"; // Or your API $.ajax({ url: url1, type: 'GET', dataType: 'json', success : function(response){ // Access the json objects like this // eg. response.status, response.data etc. // Do DOM manipulation // eg. $('#target').text(response.data) }, failure : function(response){ alert("Error! Please Contact technical support"); } }); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.