jQuery ajax load method stucked in loading [closed] - ajax

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I've searched all over the site but I couldn't find anything that helped me, so here it is:
I have this html file that when you click on Get extern it should place the content from extern.html into the div named content, but is getting stucked, when you click on the link it shows loading and that's it.
test.html file
<script type="text/javascript" src="jquery-1.9.1.js"></script>
<script type="text/javascript"><!--
$(document).ready(function() {
// select all the links with class="lnk", when one of them is clicked, get its "href" value
// adds a "loading..." notification, load the content from that URL and
// place only the paragraph which is in the #cnt into the tag with id="content"
$('a.lnk').click(function() {
var url = $(this).attr('href');
$('#content').html('<h4>Loading...</h4>').load(url+ ' #cnt p');
return false;
});
});
--></script>
</head>
<body>
<h1>Web page test.html</h1>
Get extern
<div id="content">Initial content in test.html</div>
extern.html file
<h2>Content in extern.html</h2>
<div id="cnt"><p>Some text content in extern.html</p></div>

My guess is that your trying to load an external webpage, but it's getting blocked by the same origin policy in your browser. If not, there's a quick way to debug this.
1) My favorite is to use the Chrome developer panel (open by pressing F12). Go to the network tab and try to load the external page via your jQuery. Then you can watch the network activity and see if any errors come up.
2) User $.ajax instead of $.load. See here for more options: JQuery error option in $.ajax utility
If the problem is indeed the same domain policy look into jQuery's JSONP functionality. One example is here: http://www.jquery4u.com/json/jsonp-examples/
Hope this helps!

Generally this 'Loading' appears when the script is not successfully executed or some logical/syntax error is occured. I assume you verified your script with firebug, I suggest you to check with $.noConfllict(); in case if your page has multiple script blocks and libraries conflicting each other.

Related

In mvc3 how to access the div inner text of view in controller? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I have one Div ,that is editable.when i edit the div after click one button how to access div inner text in controller...In Controller Request[""]...is possible??
It's hard to understand your question correctly, but if you are trying to process contents of a div in controller, ajax will be your best friend. You can use e.g. jQuery to load the changed div content and then make a post to your controller's action that will process it.
No this is not possible as a <div> element is not an input element that has a value posted back to the server when a <form> element is submitted. You could
Use a <textarea> or <input type="text"/> instead of a <div>
Use JavaScript on the client side to get the innertext of the <div> and include the value in the values submitted to the server.
Personally, I'd go for option 1 and simply put a <textarea> inside of the "editable" <div>

Place page title over image [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want to place an image at the top of the content <div> tag in a custom Joomla site, then place the page title over the top of the image. The site is currently being developed locally so I don't have any links sorry. The rest of the site is coming along pretty smoothly, any help with this will be greatly appreciated.
I think you are making this harder than it needs to be. First, you can add the image in the header by simply adding a module position (if there isn't one already) within your header div. Next, I am assuming you are talking about the title of a Joomla article. This can easily be displayed in the component area then moved using CSS. You already gave a container div (content). As long as you don't specify the position attribute of the divs between content and your page title, you will be able to position your title absolutely anywhere within the content div, including over the top of the image you added to the header in a module.
You will have to make changes to your index.php of your template.
Add a div above the <div class="container"> then you can make a db call using JFactory::getDBO() and fetch data you want and show it in the div.
<div class="page-name"></div>
<div class="custom_div"></div>
<div class="content"></div>
<!-- rest of the index.php divs goes here -->
if you want the specific div only in the front page, use the below code.
<?php
$app = JFactory::getApplication();
$menu = $app->getMenu();
if ($menu->getActive() == $menu->getDefault()) {
echo '<div></div>';
}
?>

styling via HTML 4 attributes is not the same across browsers [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Why is it that my CSS is not applied the same in all browsers? For example, for the below code:
<body align="center" background="F:\photos\sravan\wi7.jpg">
I can see my text which is aligned center and with background in Chrome, but not the same in Mozilla! Why is this happening?
Browsers restrict access to file:// resources for security reasons. AFAIK, you can specify image locations in the same directory only, i.e. your HTML file would also have to be in f:/photos and referenced using a relative path, ie. sravan/wi7.jpg.
Also, as pointed out in the comments, the notation you are using is not CSS. Specifying visual properties using HTML attributes is an outdated technique and it's better to switch to actual CSS. Learn about its basics e.g. here or on one of the sites recommended by Robert.
Your code is not CSS
Instead you should have HTML and CSS as in:
<body>
content
...
</body>
and body CSS
body {
background-image: url(URL to your image and not local path);
text-align: center;
}
Learn the languages
No offence but I warmly suggest you learn HTML and CSS before delving into writing any reasonable code.
Introduction to HTML
Introduction to CSS
HTML Specification
As per W3C specification body element doesn't support align attribute and background is deprecated in 4.01 and not supported in HTML5. So don't use it as an attribute. Define style using CSS:
in separate CSS file that you reference in HTML
add style element inside head HTML element
(not recommended) add style inline with your element:
<body style="text-align: center; background-image: url(wi7.jpg);">
Because of the way that CSS works having many inline styles makes your application hard to maintain and also intrduces new CSS hacks that you have to use in order for your page to render as expected. Separation of concerns rules. HTML file is your content definition, CSS file is its style. Keep them separate whenever possible.
General advice
Since browsers try to follow specification there may be differences between their rendering of HTML+CSS. Some may be very strict about it others a bit more loose. Try to stay within specification and you should get better cross-browser results.

CKEditor: unable to cancel anchor default behaviour (href page change) after mode switch (source/wysiwyg) in FF [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
We have a CKEditor in place, on a ASP.Net MVC 3 page:
var editor = CKEDITOR.replace(...);
Inside this editor we use some plugins to create several types of elements, the element causing trouble is created with this structure:
<div backendname="asfasdf" class="editableArea" contenteditable="false" displayname="asdfasdf"
fieldheight="50" fieldlength="610" fieldtype="5" maxchars="0" required="true">
<a href="google.com">
<img align="top" alt="" hspace="0" src="http://someaddress/img.jpg"
style="border-width: 0pt; border-style: solid; margin: 0pt;
width: 420px; height: 315px;" vspace="0" />
</a>
</div>
When creating this element, we are attaching (via jQuery) the click event with a function of our own, which sums up to this:
$jq(field.$).find('a').click(function (event) {
event.preventDefault();
event.returnValue = false;
return false;
});
As you can see we've been trying some variations for the event cancelation to prevent anchor behaviour. When the element is first created this works as expected. The problem araises when we switch modes in CKEditor.
For those unfamiliar with CKEditor, when you switch modes between "source" and "wysiwyg/design" the iframe that design mode uses is destroyed and replaced with a textarea. When switching back into design, the iframe is recreated and all content populated.
We've tried to use this event on CKEditor to reattach the click event, like this:
editor.on('mode', function (e) {
if (e.data.previousMode == 'source') {
$jq("iframe").contents().find('.editableArea a').click(AnchorClick);
}
});
function AnchorClick(event) {
event.preventDefualt();
event.originalEvent.preventDefault();
event.preventPropagation();
event.returnValue = false;
return false;
} (this function was separated for debugging purposes)
Again, we tried anything we could think of, but still FF follows the link inside the iframe, which causes the lose of the CKEditor and its contents.
We cannot define href="..." in the anchor tag since the information in the CKEditor is stored for future usage, therefore we must store the true href in the link.
It's a very peculiar question, I know. The truth is I can't think of anything else to do and can't find information about how to overcome FF behaviour in this particular case. Hopefully at least one of the many users of SO has faced a similar issue and can point us in the right direction.
It was a typo. This issue is solved.
function AnchorClick(event){
event.preventDefualt();
...
}

AJAX modal dialog, fire onload if referer == <whatever>

I'm trying to change my index.html to show a modal window if the referer to my site == (eg, if they come from Google, show a "Welcome Googler" dialog box with an image inside of it).
I'm using FancyBox, but I'm not married to it.
Any suggestions on how to code it? I'm a C++ programmer -- Javascript isn't my forte, so straight examples would be very much appreciated.
Thanks in advance.
You're going to need a couple things: document.referrer, and jQuery UI. jQuery UI makes dialog boxes trivially easy.
You can find an in depth example from the documentation page but for the most part, this is what you are going to need:
<script type="javascript/text">
if (document.referrer.indexOf('google.com') > -1){
$("#my-dialog").dialog("open");
}
// this is the jquery code to set up the dialog box
$(function() {
// options would go inside the dialog() function
$("#dialog").dialog();
});
</script>
Needed HTML:
<div id="my-dialog">
This is where things get displayed
</div>

Resources