Using the H5+asp.net General Handler development project, use Ajax to communicate back and forth. One scenario requires a different response from the front end based on the different data types returned by the server, and here's how to use $.ajax to implement that requirement.
$.ajax ({
' url ': ' Getwatermarkinfo.ashx ', '
type ': ' Post ',
' data ': {' Bgstyle ': bgstyle, ' watermark ': Watermark},
success:function (data, status, XHR) {
// Using the getResponseHeader method of the XMLHttpRequest object to obtain Content-type information
var ct = xhr.getresponseheader ("Content-type") | | "";
if (Ct.indexof (' Application/json ') >-1) {
if (data). Status = = ' Error ') {
alert (data). message);
}
else if (data. Status = = ' OK ') {
$ (' #watermarkImg '). attr (' src ', ' generatewatermark.ashx?bgstyle= ' + bgstyle + ' &watermark= ' + watermark);
}
else {
alert (' Unknown error! ');
}
}
else {
alert (' Unexpectecd content-type! ');
}
,
error:function (message) {
alert (' ERROR: ' + message);
}
The above is a small series to introduce the Jquery.ajax implementation of different content-type to make different responses, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!