jQuery将参数传递给函数调用,从ajax成功

时间:2022-12-08 19:34:16

I want to call a function when a jQuery Ajax request is successfull. I want to pass a parameter into a second function that apparently (it doesn't work) doesn't exist inside the jquery anonymous function.

我想在jQuery Ajax请求成功时调用一个函数。我想将一个参数传递给第二个函数,显然(它不起作用)在jquery匿名函数中不存在。

Here is my Ajax function:

这是我的Ajax功能:

function core_get_title(url,id_of_link){

                $.ajax({
                    type: "POST",
                    url: "url_handler.php",
                    data: { 
                        url: url,
                        cmd: "get_title",
                        },
                    success: function(data) {
                        core_title_auto(data,id_of_link);
                        }   
                });

            }

And when it calls core_title_auto, the id_of_link parameter is empty.

当它调用core_title_auto时,id_of_link参数为空。

Any ideas?

1 个解决方案

#1


0  

check and see whats in id_of_link before ajax call by placing an alert function

通过发出警报功能,在ajax调用之前检查并查看id_of_link中的内容

function core_get_title(url,id_of_link){
                alert("id_of_link"+id_of_link);  
                $.ajax({
                    /*...... your code */  
                });

            }

#1


0  

check and see whats in id_of_link before ajax call by placing an alert function

通过发出警报功能,在ajax调用之前检查并查看id_of_link中的内容

function core_get_title(url,id_of_link){
                alert("id_of_link"+id_of_link);  
                $.ajax({
                    /*...... your code */  
                });

            }