with including jquery-1.8.3.min.js ajax xml parsing working fine. If i including jquery.mobile-1.3.2.min.js means getting error "XMLHttpRequest cannot load http://myurl.com. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access."
I already tried
<script type="text/javascript" src="js/jquery.mobile-1.3.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$.support.cors = true;
$.mobile.allowCrossDomainPages = true;
$.ajax({
type: "GET",
url: "http://myurl.com",
dataType: "xml",
success: function(xml) {
$(xml).find('ad').each(function(){
var url = $(this).find('url').text();
alert(url);
var title = $(this).find('title').text();
var details = $(this).find('content').text();
$("#BlogList").append("<div class='blog_listing'> <div class='blog_list_title'><a href='"+$.trim(url)+"' title='"+$.trim(title)+"'>"+$.trim(title)+"</a></div><div class='blog_list_detials'><p>"+$.trim(details)+"</p></div></div>");
});
}
});
});
</script>
It's not working
I cant seem to find the jquery file added in your snapshot given,in case you have added it and still face the problem then I recommend you to try the below methodology and let me know.
Access-Control-Allow-Origin error generally comes up due to the browser web security permissions. If you are running the ajax request in chrome,then I recommend you to do disable-web-security in chrome and try it.
In case you are using MAC then in terminal type the below code and enter :-
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --disable-web-security --allow-file-access-from-files --allow-file-access --user-data-dir=~/chrome-test/ spec/runner.html
In case you are using windows go to the command prompt and go into the folder where Chrome.exe is and type
chrome.exe --disable-web-security
Try doing it and run your project in the browser that opens up after running the below code in terminal and let me know if it works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With