mardi 21 avril 2020

how to send very long data in ajax url?

i am using php and ajax together to access data from user and insert into database.problem is that it works fine with small string but when i try to send data on 10000 characters browser prompts an error saying url to long.. i can make change in php but i want it to be dynamic so i have to it using this way only.. help me plz.

function submitQuestion(){
    var x=document.forms['Ask']['title'].value;
    var y=document.forms['Ask']['description'].value;
    if(x.length ==  0 || y.length == 0){
        alert('Insufficient Data');
    }else{

        startLoading();
        console.log(y);
        var xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function(){
            if(this.readyState == 4 && this.status==200){
                console.log(this.responseText);
                if(this.responseText == "All Done"){
                    clearInterval(startLoadingClearInt);
                    alert("data Inserted");
                    // window.location.replace('../profile/userprofile.php');
                }
            }
        };

        //here x is very inn some cases and produces an error
        xhttp.open("POST","./submitQuestion.php?title="+x+"&description="+y, true);
        xhttp.send();
    }
}



Aucun commentaire:

Enregistrer un commentaire