ajax - Sending Data containing HTML Page to webMethod using C# -
i need save html file in 1 of folder of project. using jquery got complete html of page ( var content=$("#pagecontent").html()) in variable . need send html content web method using ajax call save @ location. m using
$.ajax({ url:'getpage.asmx/getpage', type:'post', data:{data:content}, success:{function(res){}}, error:{function (er){}} });
performing above approach i'm getting internal server error, , i"m not sure whether can send string having html tags web methods or not. need way per
i see in question:
performing above approach i'm getting internal server error
i not work c#, means have problems when received post inside c#. maybe because of syntax error or that.
i used have error when perform ajax request api, in php because forgot ';' after var example.
you may c# script , try figured out wrong. if not have syntax error, or something, try send string without html, , see if script work.
if does, try encode content:
$.ajax({ url:'getpage.asmx/getpage', //encode content type:'post', data:{ data: encodeuricomponent(content) }, //text || json set type c# script datatype: 'text', //callback if success res text in case success: function(res) { console.log(res); }, //callback if error er text in case error: function(er) { console.log(er); } });
i have removed success:
{function(res){}
},
in error too, not necessary
if script work this, can stock html content this, , when need can decodeuricomponent();
in javascript before append.
documentations:
encodeuricomponent();
http://www.w3schools.com/jsref/jsref_encodeuricomponent.asp
decodeuricomponent();
Comments
Post a Comment