i am making a product add page for e commerce and after the data is being submitted then a ajax call pass all the data to the query page and it stores the info to the database. but the problem is when a large amount of html data is being passed then it dosent pass anything in the description . suppose write a short paragraph in description area then it pass throught ajax easily . but whenever there is long paragraphs or lets a very large amount of html data. it fails . the code i am using is
function product()
{
var micategory=$('.micatg option:selected').val();
var misubcategory=$('.misubcatg option:selected').val();
var currency=$('.micurrency option:selected').val();
var looking_for=$('input:radio[name=lookingfor]:checked').val();
var title=$('.btitle').val();
var condition=$('input:radio[name=bcondition]:checked').val();
var buy_description=CKEDITOR.instances['textarea_description_add'].getData();
var buy_country=$('.bcountry option:selected').text();
var buy_city=$('.bcity').val();
var zipcode=$(".bzipcode").val();
var price=$(".bprice").val();
var video_link=$("#infolink").val();
var address=$(".baddress").val();
var loguser=$("#loginuser").val();
var product_id=$("#prod_id").val();
var dataString = 'category='+ micategory+'&subcategory='+misubcategory+'¤cy='+currency+'&looking_for='+looking_for+'&title='+title+'&condition='+condition+'&country='+buy_country+'&city='+buy_city+'&zipcode='+zipcode+'&price='+price+'&video_link='+video_link+'&address='+address+'&loguser='+loguser+'&product_id='+product_id+'&description='+encodeURIComponent(buy_description);
alert(dataString);
$.ajax({
type: "GET",
url: "modules/buy&sell/add_prod.php",
data: dataString,
cache: false,
success: function(html){
alert(html);
alert("Your Product is Successfully Added");
window.location = "buy.php";
}
});
}
in this due to large amount of html i used encodeURIComponent reading somewhere in stack. but still no help with this. can anyone help me with this.
Use
POSTinstead ofGET, Because of size limitation ofGET.within ajax config object.
So, it will look like: