- Subscribe to RSS Feed
- Mark Thread as New
- Mark Thread as Read
- Float this Thread for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Embed Code - jquery load/ajax
I tried a couple of methods (load & ajax) to automatically load a div when the page displays. The embedded code fails, but no error/info is returned. Anyone using something similar that works? I found a post that said to conver $ to jQuery. I tried but it still fails.
Sample Code:
// start of embedded code block
<div id="div1"></div>
<div id="div2"></div>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
// method #1 using load
<script>
jQuery('#div1').load('http://idx.trianglemls.com/index.php?OfficeList=72899&action=select&query_id=7&unique_frame_link=062...', function( response, status, xhr ) {
if ( status == "error" ) {
var msg = "Sorry but there was an error: ";
jQuery( "#div1" ).html( msg + xhr.status + " " + xhr.statusText );
}
});
</script>
<script>
jQuery( document ).ready(function(){
jQuery.ajax({
url: 'http://www.mls.com',
type: 'get',
success: function(data){
jQuery('#div2').html(data);
},
error: function (xhr, ajaxOptions, thrownError) {
var errorMsg = 'Ajax request failed: ' + xhr.responseText + ' err: ' + thrownError;
jQuery('#div2').html(errorMsg);
}
});
});
</script>
// end of embedded code block
- Labels:
-
How To
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report
- Subscribe to RSS Feed
- Mark Thread as New
- Mark Thread as Read
- Float this Thread for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
This is the displayed page
Welcome
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report
- Subscribe to RSS Feed
- Mark Thread as New
- Mark Thread as Read
- Float this Thread for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
I see the following in the developer tools console.
(index):1 Failed to load http://www.mls.com/index.html: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://194782851553015830.weebly.com' is therefore not allowed access.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report
- Subscribe to RSS Feed
- Mark Thread as New
- Mark Thread as Read
- Float this Thread for Current User
- Bookmark
- Subscribe
- Printer Friendly Page