I need to write function which prepare me a HTML to inuput into my site, I tried like this
function prepareHTML(valId){
$.ajax({
type: "POST",
url: "SOAPulr_getData",
data: {operationId: valId}
})
.done(function(result, status, jqXHR){
var def = $.Deferred();
var response = jqXHR.responseText;
var outputHTML;
[... here i generate HTML code ...]
def.resolve(outputHTML);
return def.promise();
});
}
now when i tried to run this function:
prepareHTML(22)
.done(function(data){
console.log(data)
});
I get an error:
TypeError: prepareHTML(…) is undefined
when I run prepareHTML(22) there is no error in console.
What I do wrong?
—
Best regards
ssnake
2
Answers
Yes I can do this like that:
and it works but then I must to generate my HTML into done function:
Question is: is it possible to pre-process the respone to have HTML ready in the done function
I need something like this:
prepareHTML
has noreturn
statement so it returnsundefined