Saturday, May 25, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  4] [ 3]  / answers: 1 / hits: 20154  / 9 Years ago, wed, october 14, 2015, 12:00:00

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}})

More From » jquery

 Answers
19

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.


[#64749] Sunday, October 11, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
janeth

Total Points: 498
Total Questions: 91
Total Answers: 89

Location: Malaysia
Member since Wed, May 11, 2022
2 Years ago
;