I have a codeigniter application.In that i call the controller function using ajax/jquery.But when i passing variable with space value it becomes wrong loading of another view page.
This is my view page code
var cnt=$("#search_agency_res").serialize();
$.ajax({
type: "POST",
url: "<?php echo base_url();?>index.php/addAgency/agency_map_result/"+region+"/"+country+"/"+agency,
data: cnt,
success: function(valmsgnew){
$("#map").css("display","block");
$("#map").html(valmsgnew).show();
}
});
search_agency_res
is the name of form.Here the variable region
must have values in all time but country,agency
may have ""(space).How can i handle this?
The issue is only occuring when country,agency
have sapce or null value.If it have any valid value except space then everything is perfect.
Try passing data as post:
var cnt=$("#search_agency_res").serialize(); $.ajax({ type: "POST", url: "index.php/addAgency/agency_map_result, data: "cnt="+cnt+"&rregion="+region+"&country="+country+"&agency="+agency, success: function(valmsgnew){ $("#map").css("display","block"); $("#map").html(valmsgnew).show(); } });
Hope it helps