i'm trying to make a ajax update in prototype with some values from a multirecordselect that sends a requests like.
Parameters: {"action"=>"use_campaign", "campaigns"=> ["27929","27932"] , "advertiser_id"=>"", "controller"=>"admin/reporting", "ad_id"=>""}
as you can see the request sends the "campaigns" elements as an array of values, i'm trying to do the same with this js code over prototype 7.
// get the campaigns
var campaign_ids = {};
var campaigns = $('filter_form').getInputs("hidden","report[campaigns][]");
campaigns.each( function(field) {
campaign_ids.push(field.value);
});
new Ajax.Updater('ad_filter', '/admin/reporting/use_campaign', {
method : 'get',
asynchronous : true,
evalScripts : true,
parameters : {
'advertiser_id' : $('filter_form')['report[advertiser_id]'].value,
'ad_id' : $('filter_form')['report[ad_id]'].value,
'campaigns' : campaign_ids
}
});
the campaigns_ids is getting the correct info as an array like:
[ "27929", "27932" ]
but seems that prototype ajax update is sending a request like:
http://my_domain/admin/reporting/use_campaign?ad_id=&advertiser_id=&campaigns=27929&campaigns=27932
what sends parameters like:
Parameters: {"action"=>"use_campaign", "campaigns"=> "27929" , "advertiser_id"=>"", "controller"=>"admin/reporting", "ad_id"=>""}
I also tryed with
Object.toJSON(campaign_ids)
but i only get an escaped string like
Parameters: {"action"=>"use_campaign", "campaigns"=>"[\"27929\",\"27932\"]" , "advertiser_id"=>"", "controller"=>"admin/reporting", "ad_id"=>""}
There is anyway to do this as I wish?
Thanks for all.
i'm trying to make a ajax update in prototype with some values from a multirecordselect that sends a requests like.
Parameters: {"action"=>"use_campaign", "campaigns"=> ["27929","27932"] , "advertiser_id"=>"", "controller"=>"admin/reporting", "ad_id"=>""}
as you can see the request sends the "campaigns" elements as an array of values, i'm trying to do the same with this js code over prototype 7.
// get the campaigns
var campaign_ids = {};
var campaigns = $('filter_form').getInputs("hidden","report[campaigns][]");
campaigns.each( function(field) {
campaign_ids.push(field.value);
});
new Ajax.Updater('ad_filter', '/admin/reporting/use_campaign', {
method : 'get',
asynchronous : true,
evalScripts : true,
parameters : {
'advertiser_id' : $('filter_form')['report[advertiser_id]'].value,
'ad_id' : $('filter_form')['report[ad_id]'].value,
'campaigns' : campaign_ids
}
});
the campaigns_ids is getting the correct info as an array like:
[ "27929", "27932" ]
but seems that prototype ajax update is sending a request like:
http://my_domain/admin/reporting/use_campaign?ad_id=&advertiser_id=&campaigns=27929&campaigns=27932
what sends parameters like:
Parameters: {"action"=>"use_campaign", "campaigns"=> "27929" , "advertiser_id"=>"", "controller"=>"admin/reporting", "ad_id"=>""}
I also tryed with
Object.toJSON(campaign_ids)
but i only get an escaped string like
Parameters: {"action"=>"use_campaign", "campaigns"=>"[\"27929\",\"27932\"]" , "advertiser_id"=>"", "controller"=>"admin/reporting", "ad_id"=>""}
There is anyway to do this as I wish?
Thanks for all.
Share Improve this question edited Mar 28, 2012 at 13:24 clockworkgeek 37.7k9 gold badges91 silver badges127 bronze badges asked Mar 28, 2012 at 11:05 andresbravogandresbravog 6036 silver badges9 bronze badges 1- ok stupid me, just put the right parameter 'campaigns[]' instead of 'campaigns' . Sorry for ask =) – andresbravog Commented Mar 28, 2012 at 11:23
1 Answer
Reset to default 7It looks like you use PHP as a back-end framework.
To make sure PHP understands array-like GET parameters, you need to add a []
to the parameter name:
parameters : {
//...
'campaigns[]' : campaign_ids
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744786689a4593669.html
评论列表(0条)