$.ajax({
url: url,
type: 'POST',
cache: false,
data: "param=value",
success: function (html) {
if (loading_div != '') {
document.getElementById(loading_div).innerHTML = "<img src ='" + fullurl + "/img/loading.gif' />";
document.getElementById(loading_div).style.display = 'none';
}
$("#" + update_div).html(html).animate({
opacity: "9.7"
}, "slow");
}
});
This is my code. I would like to pass one paragraph to the php function by url
http://mywebsite.com/functionname/Pragraph from the text editor will come here (nearly 1000 words).
How can I pass it?
Pass it into the data parameter as an object, rather than a string of key-value pairs:
var paragraph = "Lorem ipsum dolor sit amet...";
$.ajax({
url: url,
type: 'POST',
cache: false,
data: {"paragraphParam" : paragraph},
success: function(html){
if(loading_div!=''){
document.getElementById(loading_div).innerHTML = "";
document.getElementById(loading_div).style.display ='none';
}
$("#"+update_div).html(html).animate({opacity: "9.7"}, "slow");
}
});
By the way, since you're using JQuery, you may want to take full advantage of its other built-in functions. For example:
document.getElementById(loading_div).innerHTML = "";
and
$("#"+loading_div).html("");
...are identical.
So are:
document.getElementById(loading_div).style.display ='none';
and
$("#"+loading_div).css("display", "none");
...which is essentially the same as:
$("#"+loading_div).hide();
You'll want to create an object for your data, inside of it, set a paragraphVal—or whatever—to the text in your paragraph
data: { paragraphVal : $("#yourParagraphId").text()},
Also, the other answer has pointed out the simpler way to clear the html from an element. Here's a simpler way to hide an element:
$("#loading_div").hide();
This can replace
document.getElementById(loading_div).style.display ='none';