I have following Ajax Success method :
我有以下Ajax Success方法:
success: function(data, el){
var parent = el.find(".jFiler-jProgressBar").parent();
el.find(".jFiler-jProgressBar").fadeOut("slow", function(){
$("<div class=\"jFiler-item-others text-success\"><i class=\"icon-jfi-check-circle\"></i> Success <b class=\"text-danger\"> <a href=\"#delete_upload_image\">Delete</a></b></div>").hide().appendTo(parent).fadeIn("slow");
});
console.log(data);
},
In this success method you see that I have a link which is :
在这个成功方法中,您会看到我有一个链接:
<a href=\"#delete_upload_image\">Delete</a>
and
和
console.log(data)
This console.log(data)
is returning following String :
此console.log(数据)返回以下字符串:
mpic_list_573ecaafae8220.41741946 |76|40
Now I want call a php page e.g : delete_upload_image.php
after click on this link <a href=\"#delete_upload_image\">Delete</a>
with a string mpic_list_573ecaafae8220.41741946
and 76
and 40
现在我想调用一个php页面,例如:delete_upload_image.php点击此链接删除后,用字符串mpic_list_573ecaafae8220.41741946和76和40
I mean :
我的意思是 :
In delete_upload_image.php
page I can get 3 string which is passed when I click on the delete
link. `
在delete_upload_image.php页面中,我可以获得3个字符串,当我点击删除链接时会传递该字符串。 `
4 个解决方案
#1
1
You must either bind the click to a function where you send the user to the desired page or directly make a link in the button.
您必须将单击绑定到将用户发送到所需页面的功能,或者直接在按钮中创建链接。
First, if you want to send the differents params separately, you must split them.
首先,如果要单独发送不同的参数,则必须将它们拆分。
var params = data.split('|');
And then use it as you want, for example bind the click method to the new link to create a new ajax call.
然后根据需要使用它,例如将click方法绑定到新链接以创建新的ajax调用。
$('#delete_upload_image').on('click', function() {
var params = data.split('|');
var url = "delete_upload_image.php?param1=" + params[0] +"¶m2=" + params[1] + "¶m3=" + params[2];
// Make AJAX call as you want to url
$.get(url);
});
#2
0
Catch your parameters in your data using split method :
使用拆分方法在数据中捕获参数:
var stringParam = data.split('|')[0];
var int1Param= data.split('|')[1];
var int2Param= data.split('|')[2];
then put your parameters inside your link :
然后将您的参数放在链接中:
$("<div class=\"jFiler-item-others text-success\"><i class=\"icon-jfi-check-circle\"></i> Success <b class=\"text-danger\"> <a href=\"delete_upload_image.php?string="+ stringParam +"&int=" + int1Param + "&secondint=" + int2Param + "\">Delete</a></b></div>").hide().appendTo(parent).fadeIn("slow");
#3
0
- you must put your data in your link tag:
- 您必须将数据放入链接标记中:
<a href=\"#delete_upload_image\" data-params='" + data + "'>Delete</a>
- then you can send delete requests to "delete_upload_image.php" by below codes:
- 然后你可以通过以下代码发送删除请求到“delete_upload_image.php”:
$(function(){
$('body').on('click', '[href=#delete_upload_image]', function() {
var params = $(this).data('params').split('|');
var url = "delete_upload_image.php?param1=" + params[0] +"¶m2=" + params[1] + "¶m3=" + params[2];
// Make AJAX call as you want to url
$.get(url);
});
});
#4
0
now I understand what is your problem;
现在我明白你的问题是什么;
You want to get the parameters from console.log.
您想从console.log获取参数。
but you can not get the console.log value directly.
但是你无法直接获得console.log值。
What you can do is:
你能做的是:
- hook the console.log function so that you store when it logs by this code:
- 挂钩console.log函数,以便在通过此代码记录时进行存储:
var store = '';
var oldf = console.log;
console.log = function(){
store = JSON.stringify(arguments);
oldf.apply(console, arguments);
}
- use below function to get parameters from console_store variable and delete image:
- 使用下面的函数从console_store变量获取参数并删除图像:
function delete_image()
{
var params = store.split('|'),
queryString = $.param({param0:params[0], param1:params[1], param2:params[2]}),
url = "delete_upload_image.php?" + queryString;
$.get(url);
}
- call the function on link click:
- 在链接点击上调用该功能:
$('body').on('click', '[href=#delete_upload_image]', delete_image);
#1
1
You must either bind the click to a function where you send the user to the desired page or directly make a link in the button.
您必须将单击绑定到将用户发送到所需页面的功能,或者直接在按钮中创建链接。
First, if you want to send the differents params separately, you must split them.
首先,如果要单独发送不同的参数,则必须将它们拆分。
var params = data.split('|');
And then use it as you want, for example bind the click method to the new link to create a new ajax call.
然后根据需要使用它,例如将click方法绑定到新链接以创建新的ajax调用。
$('#delete_upload_image').on('click', function() {
var params = data.split('|');
var url = "delete_upload_image.php?param1=" + params[0] +"¶m2=" + params[1] + "¶m3=" + params[2];
// Make AJAX call as you want to url
$.get(url);
});
#2
0
Catch your parameters in your data using split method :
使用拆分方法在数据中捕获参数:
var stringParam = data.split('|')[0];
var int1Param= data.split('|')[1];
var int2Param= data.split('|')[2];
then put your parameters inside your link :
然后将您的参数放在链接中:
$("<div class=\"jFiler-item-others text-success\"><i class=\"icon-jfi-check-circle\"></i> Success <b class=\"text-danger\"> <a href=\"delete_upload_image.php?string="+ stringParam +"&int=" + int1Param + "&secondint=" + int2Param + "\">Delete</a></b></div>").hide().appendTo(parent).fadeIn("slow");
#3
0
- you must put your data in your link tag:
- 您必须将数据放入链接标记中:
<a href=\"#delete_upload_image\" data-params='" + data + "'>Delete</a>
- then you can send delete requests to "delete_upload_image.php" by below codes:
- 然后你可以通过以下代码发送删除请求到“delete_upload_image.php”:
$(function(){
$('body').on('click', '[href=#delete_upload_image]', function() {
var params = $(this).data('params').split('|');
var url = "delete_upload_image.php?param1=" + params[0] +"¶m2=" + params[1] + "¶m3=" + params[2];
// Make AJAX call as you want to url
$.get(url);
});
});
#4
0
now I understand what is your problem;
现在我明白你的问题是什么;
You want to get the parameters from console.log.
您想从console.log获取参数。
but you can not get the console.log value directly.
但是你无法直接获得console.log值。
What you can do is:
你能做的是:
- hook the console.log function so that you store when it logs by this code:
- 挂钩console.log函数,以便在通过此代码记录时进行存储:
var store = '';
var oldf = console.log;
console.log = function(){
store = JSON.stringify(arguments);
oldf.apply(console, arguments);
}
- use below function to get parameters from console_store variable and delete image:
- 使用下面的函数从console_store变量获取参数并删除图像:
function delete_image()
{
var params = store.split('|'),
queryString = $.param({param0:params[0], param1:params[1], param2:params[2]}),
url = "delete_upload_image.php?" + queryString;
$.get(url);
}
- call the function on link click:
- 在链接点击上调用该功能:
$('body').on('click', '[href=#delete_upload_image]', delete_image);