0

i wrote a code which send a get request by jquery-ajax,also i use a call back to return the result of this request.But the returned value has no applicable method in itself(when i press alt+space i have nothing in that menu).the question is why? any solution?

var result;
var reg = new RegExp(/^.*(youtu.be\/|v\/|e\/|u\/\w+\/|embed\/|v=)([^#\&\?]*).*/);
var split = window.location.href.match(reg);
var videoidxn = split[2];
var url = `https://video.google.com/timedtext?lang=en&v=` + videoidxn;

function GTA(callback) {
    var res;
    $.ajax({
        type: 'Get',
        url: url,

        success: function(response) {
            callback(response)
        },

    })
}
GTA(function(response) {
    result = response;
    console.log(result)
})

for example if i want to run the last part of code like this :(add the find method to response)

GTA(function(response) {
    result = response.find('text');
    console.log(result)
})

i will get the following error: Uncaught Type Error: response.find is not a function

Quentin
  • 800,325
  • 104
  • 1,079
  • 1,205
moein
  • 21
  • 2
  • 1
    What data type do you expect `response` to be? What do you get if you `console.log` it? What do you get if you `console.log` `typeof response`? – Quentin Aug 01 '20 at 19:38
  • when i use console.log i get a transcript tag with a lot of text tag in it...typeof response in console.log is object – moein Aug 02 '20 at 05:34
  • i want to perform find() method on response but find is not in intelisense list(is not shown) – moein Aug 02 '20 at 05:35

0 Answers0