i need a help with this code:
我需要这个代码的帮助:
i need send service, data and content params... but does not work ((
我需要发送服务,数据和内容参数...但不起作用((
var addons = {};
$.ajax({
'url': 'http://site.com/index.php',
dataType:'jsonp'
success:function()
{
addons.name = 'Some name';
addons.caption = 'Some caption';
addons.description = 'Some description';
}
});
var data = {
'services' : 1,
'data' : addons,
'content' : $(self).find('textarea').val()
};
$.ajax({
'url' : 'index.php',
'dataType' : 'json',
'type' : 'post',
'data' : data,
success:function(response){
//...
}
});
Send Post:
services=1&content=hi
1 个解决方案
#1
1
You need to define the object´keys and values witin the brackets or you define an class like function and than save the values. But for your target the following should be working fine.
您需要在括号中定义对象的键和值,或者您定义类似函数的类,而不是保存值。但是对于你的目标,以下应该可以正常工作。
var addons = {
name: 'Some name',
caption: 'Some caption',
description: 'Some description'
};
Kind Regards
#1
1
You need to define the object´keys and values witin the brackets or you define an class like function and than save the values. But for your target the following should be working fine.
您需要在括号中定义对象的键和值,或者您定义类似函数的类,而不是保存值。但是对于你的目标,以下应该可以正常工作。
var addons = {
name: 'Some name',
caption: 'Some caption',
description: 'Some description'
};
Kind Regards