javascript - ajax request from function -
i want write function has string parameter(url) , make ajax request url.
i tried this:
<html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>jquery basic</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script> $(document).ready(function() { var encodedurl = encodeuricomponent("https://www.yahoo.com"); alert(encodedurl); $('#submit1').bind('click', function() { $.ajax({ url: encodedurl, contenttype: 'application/x-www-form-urlencoded; charset=utf-8', crossdomain: true, cache: false, type: 'get', async: false, success: function( result ) { alert("s"); alert(result); }, error: function(xmlhttprequest, textstatus, errorthrown) { alert("error"); alert(xmlhttprequest); alert(textstatus); alert(errorthrown); } }); }); }); </script> </head> <body> <a>jquery test page</a><br> <input id="submit1" type="button" value="submit"/> </body> </html>
when sending encoded url there error without detail. if sending string error is: networkerror: failed execute 'send' on 'xmlhttprequest': failed load 'https://www.yahoo.com/?_=1502748918475', or other site. i've tried "play" parameters (contenttype, async,cache, creossdomain etc) no success.
thanx
Comments
Post a Comment