mod_proxy_html and AJAX Response - mod-proxy-html

I am using mod_proxy_html and the AJAX response is wrapped inside HTML
<html>
<body>
<p>AJAX RESPONSE</p>
</body>
</html>
This is done by mod_proxy_html and I want to avoid this happening.

In general mod_proxy_html is only supposed to act on responses with Content-Type set to text/html or application/xhtml+xml: maybe you can change your Ajax response's content type?

Related

404 error from binding a background url even with ng-cloak

I am binding the background url css property in this way:
<div class="ng-cloak" style="background-image: url({{image.url}})"></div>
all the images are loaded correctly but in the console I have:
GET http://localhost:8100/%7B%7Bimage.url%7D%7D 404 (Not Found)
even if I use the class ng-cloak.
Does someone know how to avoid this error and this bad request?
Try to use ng-style instead because angular will not check none ng-*
https://docs.angularjs.org/api/ng/directive/ngStyle

Render json instead of html with angularjs

Want to build a very simple app that both has some html pages but will allow for an api as the output is just some calculations done by js.
I want to render a json output from my controller and not render html file. Any ideas how to do so with angularjs?
The problem is that a JSON document will be a single request, where the returned content has content type application/json.
If you want Angular.js, which is a frontend library, you need to make a request for an HTML document (and render the necessary HTML markup in the process), then for the angular.js library. What is rendered afterwards is still HTML (content type: text/html).
So the answer is: no, you cannot do that with Angular.js.
You will need a server-side script to output a properly formatted JSON (and nothing else) and the correct Content-Type header.
Here is a AngularJS module called json. Use it as a filter in your output.
Usage (In HTML Template Binding):
{{ json_expression | json }}
Usage (In JavaScript):
$filter('json')(object)
Where the object is
Any JavaScript object (including arrays and primitive types) to filter.
Example:
<pre>{{ {'name':'value'} | json }}</pre>
Output:
{
"name": "value"
}

AngularJS w/ noscript

I am attempting to create a SPA using AngularJS as the main view for my website. I'm using ServiceStack on the server-side and can therefore cleanly serve HTML or JSON requests depending on what's accessing it. My main concern is the use of script blockers, preventing AngularJS from rendering the page properly. So far my main way of working is to render static pages, and inject a small script that redirects to the AngularJS-powered pages if it detects if Javascript is enabled. This works great since every URL works fine when the user begins at the static pages, but I've ran into a couple of snags.
Browsing to a link which includes the "?View=SPA" breaks the page if JavaScript is disabled
This causes the first page loaded to be loaded twice.
I'm looking for an alternative, but so far I haven't found any clean solutions. I was thinking about including the "?View=SPA" as a POST variable, but I'm still iffy on that implementation.
Any thoughts?
Instead of redirecting to an other page, I would implement both cases in the same HTML File as follows:
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<style>.hideIfNoScript {display: none}</style>
</head>
<body ng-app ng-init="msg = 'hello world'">
<input class="hideIfNoScript" ng-model="msg" />
<p class="hideIfNoScript">{{msg}}</p>
<noscript>
<p>Content without javascript</p>
</noscript>
<script type="text/javascript">
var myEl = angular.element( document.querySelectorAll( '.hideIfNoScript' ) );
myEl.removeClass('hideIfNoScript');
</script>
</body>
</html>
The CSS Class hideIfNoScript in the head section makes sure that all HTML Tags with this class are never shown to the user, if javascript is disabled.
The noscript tag shows the alternative content.
If javascript is enabled, the little script at the end of the body section makes those elements visible. And in this case, the contents of the noscript tag are hidden.
Browsing to a link which includes the "?View=SPA" breaks the page if JavaScript is disabled
Hide those links by default:
a[href*='SPA'] { display: none; }
This causes the first page loaded to be loaded twice
Use a cookie on a browser-check page which loads the first page in an iframe or redirects to it to avoid this.
References
Track Non-JavaScript Visits In Google Analytics

How to do a 'HTTP-POST' with HyperlinkButton

I have a silverlight application where users can type in a SQL-query in the application, then the server returns the query result as an Excel file.
Users click on a download link, which is linked to a HttpHandler in the server which generates the excel file. After some research[1] I found out that using the HyperlinkButton control is the most robust way of providing links to file without the hassles of browser's popup security settings.
I need to send the SQL query, which can get quite long, as a parameter to the HttpHandler.
I can't include it in the url as querystrings(HTTP GET) due to size limitations.
Is there a way to do a 'HTTP-POST' with HyperlinkButton?
[1] Browser.HtmlPage.Window.Navigate is blocked but HyperlinkButton isn't - why?
In that case I think you can try sending a get/post request using jquery.
Post request API documentaton: http://api.jquery.com/jQuery.post/
Get Request API documantation: http://api.jquery.com/jQuery.get/
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
<script>
function f(){
$.post("http://www.w3schools.com/jquery/demo_test_post.asp",
{
name:"Donald Duck",
city:"Duckburg"
},
function(data,status){
alert("Data: " + data + "\nStatus: " + status);
}
)};
</script>
</head>
<body>
Send an HTTP POST request to a page and get the result back
</body>
</html>
Instead of Using Links Why just you make the buttons look like Links instead. One perfect example of buttons been shown as links is the Facebook. It has several number of buttons in a post, but all of them are shown as links. Here is the Css Code that what it makes a button look like a link. You can always change the look and feel of the link(perhaps Button).
Here the css code for the button.
button {
background:none!important;
border:none;
padding:0!important;
/* Do all your Styling to the Button here. It will look like a link instead. */
}
Button HTML Code.
<button>Your Button Here.</button>
Hope that Solves your Problem. Thank You.

google +1 button not showing up

I've added the required tags, but it is still not showing. I've added this in head:
<script type="text/javascript" src="https://apis.google.com/js/plusone.js">
{lang: 'lt', parsetags:'explicit'}
</script>
and this in the body:
<g:plusone href="http://www.fanuspinta.lt/katalogas/lietuva-mar%C5%A1kin%C4%97liai-31"></g:plusone>
At first I thought it didn't show up because I was using a local server, but now it's in production, and still not showing.
URL in case: http://www.fanuspinta.lt/katalogas/lietuva-mar%C5%A1kin%C4%97liai-31
Thanks for any ideas.
I used a html5 tag like shown here without the data-href attribute, dynamically added it afterwards (when the lightbox was loaded) and explicitely loaded the div containing the plusone code at the end.

Resources