开发者

save the html once we call html through ajax

I want to call one html through ajax. once i get the response, i need to save that response as html on the spefied location

how can i do that?

I am calling ajax function using开发者_开发百科 jquery as like below.

$.ajax({    
    type: "POST",    
    url: "../../../project/html/TC_print.html",
    success: function(msg){    
        //once it success.. i need to save it as html on desktop
    }  
 });

success call back, i need to save it as html on desktop


//once it success.. i need to save it as html on desktop

Forget about it. For security reasons, javascript that runs inside a browser doesn't have access to files on the client computer. Simply think of the consequences if this was possible. You probably wouldn't have been writing this question nor I have been writing this answer at the very moment as our computers would have been hacked badly. You visit a site and files start popping on your desktop. You visit a malicious site and viruses start popping everywhere, not only on your desktop.


JavaScript prevents you from saving files to a users computer for security reasons, You'd need to write the file to a server and then prompt the user to download the file by putting it in a ZIP or something similar.


I don't think that with javascript alone you will be able to save on the desktop but I might be mistaken. What I would do will to make another call from the success handler to a php script and pass in the html, then use PHP protocols to save file on desktop. Cheers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜