I am trying to get the response of this url. But when I check the console error message appears:
Uncaught TypeError: response is not a function
What is the possible problem?
var uri = pbxApi+"/conference/participants/"+circle+"/"+data.conference+"/"+data.uniqueid+'?jsonp=response';
getJsonData(uri, function(res){
});
This is my function.
var getJsonData = function(uri,callback){
$.ajax({
type: "GET",
dataType: "jsonp",
url: uri,
jsonpCallback: 'response',
cache: false,
contentType: "application/json",
success: function(json){
callback(json);
}
});
}
this is my response:
response({"_id":"56177d3b3f2dc8146bd8565c","event":"ConfbridgeJoin","channel":"SIP/192.168.236.15-0000005e","uniqueid":"1444379955.224","conference":"0090000293","calleridnum":"0090000290","calleridname":"0090000290","__v":0,"status":false,"sipSetting":{"accountcode":"0302150000","accountcode_naisen":"203","extentype":0,"extenrealname":"UID3","name":"0090000290","secret":"Myojyo42_f","username":"0090000290","context":"innercall_xdigit","gid":101,"cid":"0090000018"}})
As it is written here:
jsonpCallback Type: String or Function() Specify the callback function name for a JSONP request. This value will be used instead of the random name automatically generated by jQuery. It is preferable to let jQuery generate a unique name as it'll make it easier to manage the requests and provide callbacks and error handling. You may want to specify the callback when you want to enable better browser caching of GET requests. As of jQuery 1.5, you can also use a function for this setting, in which case the value of jsonpCallback is set to the return value of that function.
So by setting jsonpCallback property of your ajax object, you are passing a name of a function (or a function itself from jQuery 1.5) that should be treated as a callback. That means that if you set its value to 'response', a response() function should be declared.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With