New custom module creating action for ossn ajax call

Ashwin Shahi Posted in Component Development 8 years ago

Hello all,

I am creating a creating a "action" for ajax call.

ossn_register_action('post/approve','actions/post/approve.php'); 

with this code the URL for ajax is working but not able to send and receive data from post/approve.php

code for approve.php

<?php
$postverification = new OssnPostapprove;
$data = $_POST['post_id'];

echo $data;

jquery code to make ajax call

    Ossn.Approvepost = function(post_id){
    var datalist = 'post_id = '+post_id;
    Ossn.ajaxRequest({
        url:Ossn.site_url+'action/post/approve',
        data:datalist,
        beforeSend: function(request) {
            console.log(datalist);
        },
        callback: function(callback) {
            console.log(callback)
        }
    }); 
}
Replies
in Ashwin Shahi Replied 8 years ago

Hello Arsalan,
thanks for the reply,
as you suggested i changed the function as
Ossn.Approvepost = function(postid){
var datalist = 'post
id = '+postid;
Ossn.ajaxRequest({
url:Ossn.site
url+'action/post/approve?data='+post_id,
beforeSend:function(request){
console.log(datalist);
},
callback: function(callback) {
console.log(callback)
}
});
}

but now its not making any ajax call can you please let e know why the ajax call is not happening

Indonesian Arsalan Shah Replied 8 years ago

The Ossn.ajaxRequest isn't supposed to work same like jquery ajax() the paramter data:datalist, is invalid. You need to specify the data into URL like ?data=xx