I have problem with IIS does not read the URL.
Failed to load resource: the server responded with a status of 503 (Service Unavailable)
My project is on Asp.net MVC
I have used a Jqx grid on my project but the grid does not load data on IIS.
How can I convert the URL to Action Link #url.action, so the IIS can read?
My URL on my grid.
url: "/Home/GetIMScompinfo?CompanyName=" + $("#CompanyName").val() + "&StoreName=" + $("#StoreName").val() + "&ComputerName=" + $("#ComputerName").val() + params
url: "/Home/GetSubItems?scopeId=" + id
url: "/Home/GetIMScompinfo?CompanyName=" + $("#CompanyName").val() + "&StoreName=" + $("#StoreName").val() + "&ComputerName=" + $("#ComputerName").val() + params
url: "/Home/GetSubItems?scopeId=" + id
I don't know what is the difference between the two getting the value. So I give the sample script for the first url.
<button class="btn-class" id="press" type="button" onclick="changeHref1()">Genrate first url</button>
<script type="text/javascript">
function changeHref1() {
var url = '#Url.Action("About","Home")';
var company = $('#CompanyName').val();
var store = $('#StoreName').val();
var computer = $('#ComputerName').val();
window.location.href = url + '?CompanyName=' + company + '&StoreName=' + store + '&ComputerName=' + computer;
}
</script>
Related
Heyho, I want to add GET params like?USER_NAME=Max&USER_ID=01 to the URL if the page gets reloaded. I already got a few snippets for changing the URL / adding params. But I need something to detect the page reload and execute a function. Or a way to change the path of the Url directly if the page gets reloaded.
I tried several things like beforeunload and navigation types.
$(window).bind('beforeunload', function() {
// EDIT: vars like uname etc are defined
var newurlgetstring = "?USER_NAME=" + uname + "&USER_EMAIL=" + uemail + "&LAST_NAME=" + lname + "&PRE_NAME=" + fname + "&UTITEL=" + utitel + "&U_ID_T=" + uidt + "&MV=" + mv + "&V=" + uv ;
var newurl = window.location.protocol + "//" + window.location.host +window.location.pathname + newurlgetstring;
window.history.pushState({path:newurl},'',newurl);
});
But I want able to execute a function with beforeunload. I was just able to display a return question.
I'm very new at node so bear with me. I'm trying to download a series of images from an external server. So far I have been able to get it working on a limited basis. When I run the below code, only about half of the images make it though to the web page. I know that I'm not doing this correctly, and am looking for some guidance. Here is the code that I have so far
var request = require("request"),
fs = require("fs"),
views = ['sitename1', 'sitename2', 'sitename3'...]
for (var view in views) {
request({
url: 'http://' + SERVERURL + '/api/2.2/sites/' + siteID + '/workbooks/' + views[view]['workbookID'] + '/views/' + views[view]['id'] + '/previewimage',
headers: {
'Content-Type': 'image/png',
'X-Tableau-Auth': authToken
}
, encoding: 'binary'}).pipe(
fs.createWriteStream('./public/images/thumbnails/' + SITE + '/views/' + views[view]['url'] + '.png'
))
};
I want to point out that this does get some of the images saved correctly. I believe what I'm missing is a callback to make sure that the file has been successfully saved before moving on to the next item in the list. I have no idea how to implement that.
Another quick note (not important) is that I'm trying to download images from a Tableau Server using the REST api.
The face you're getting about half the images makes me wonder if you are using Tableau Online? If so, you need to ensure you're using the URI per the docs (http://onlinehelp.tableau.com/current/api/rest_api/en-us/help.htm#REST/rest_api_concepts_fundamentals.htm#tableau-online-uris).
Just figured it out using the async module
async.eachSeries(views, (function(view, callback) {
var thumbPath = 'public/images/thumbnails/' + req.session.SITE + '/views/' + req.session.views[view]['url'] + '.png'
request({
url: 'http://' + SERVERURL + '/api/2.2/sites/' + req.session.siteID
+ '/workbooks/' + req.session.views[view]['workbookID'] + '/views/' + req.session.views[view]['id'] + '/previewimage',
headers: {
'Content-Type': 'image/png',
'X-Tableau-Auth': req.session.authToken
}
}).pipe(
upload(thumbPath));
callback()
}),
function(err){
if(err){
console.log("a thumb failed to download")
} else {
console.log("all thumbs downloaded")
}
}
)
I'm trying to generate a link using following
$(this).parent().attr('href', '#Url.Action("Create", "Home"' + '?clientId=' + clientId + '&clientName=' + clientName);
somewhere I read that I need to isolate this Url.Action with controller and action into variable so I tried with this
var a = '#Url.Action("Create", "Home"';
$(this).parent().attr('href', a + '?clientId=' + clientId + '&clientName=' + clientName);
But this still doesn't work.
In browser I'm getting
http://localhost:1328/Home/Index2/#Url.Action%28%22Create%22,%20%22Home%22?clientId=181&clientName=undefined
Another option is to store the url with data-* attributes and access them. In the View you can add the below attribute:
data-url='#Url.Action("Create", "Home")'
Now you can access this in the script with:
var base = $(this).data('url');
$(this).parent().attr('href', base + '?clientId='+ clientId +'&clientName=' + clientName);
Your script should be on Razor page in order to make #Url.Action helper work.
When you place it there this should work:
//this line should generate /Home/Create string
var urlNoParam = '#Url.Action("Create", "Home")';
//and here you just add params as you want
$(this).parent().attr('href', urlNoParam + '?clientId=' + clientId + '&clientName=' + clientName);
I am trying to share my custom link on facebook using this javascript function,
function postToFacebook(title, summary, image_url, U)
{
window.open('http://www.facebook.com/dialog/feed?app_id= ' + fb_app_id + '&display=popup&caption=' + title + '&description='+ summary + '&redirect_uri=' + encodeURIComponent('http://facebook.com') + '&link=' + encodeURI(U) + '&picture=' + image_url,'sharer','toolbar=0,status=0,width=548,height=325');
}
In my "U" parameter I have this link => "http://localhost:4000/rings/solitaire-rings/lst?utf8=%E2%9C%93&min_price=&max_price=&name=solitaire-rings&category=rings&fashion_type=false&search=&gallery_order=&new_arrival=&best_seller=&metal_white=on&commit=APPLY"
and when user clicks on the link which is shared on facebook , user should get redirected to this link. forget about root url i.e. localhost:4000, because on production environment its considering required url.
the problem is that whne i am sharing this url on facebook user is getting redirected to "http://localhost:4000/rings/solitaire-rings/lst?utf8", and its not taking care of further parameters which are "%E2%9C%93&min_price=&max_price=&name=solitaire-rings&category=rings&fashion_type=false&search=&gallery_order=&new_arrival=&best_seller=&metal_white=on&commit=APPLY"
basicaaly I supposed to get this URL "http://admin.velvetcase.com/rings/lst?utf8=%E2%9C%93&min_price=&max_price=&name=rings&fashion_type=false&search=&gallery_order=&new_arrival=&best_seller=&search_material_id[]=Diamond&commit=APPLY" , but when I am sharing mu URL on facebook I am getting this one "http://admin.velvetcase.com/rings/lst?utf8=%E2%9C%93&%3Bmin_price&%3Bmax_price&%3Bname=rings&%3Bfashion_type=false&%3Bsearch&%3Bgallery_order&%3Bnew_arrival&%3Bbest_seller&%3Bsearch_material_id[0]=Diamond&%3Bcommit=APPLY" , which is not giving e required output.
Here is what I did successfully
var sharingUrl = "https://www.facebook.com/dialog/feed?app_id="+ facebookAppID +
"&link=" + sharingUrl +
"&name=" + encodeURIComponent(title) +
"&caption=" + encodeURIComponent(caption) +
"&description=" + encodeURIComponent(content) +
"&picture=" + encodeURIComponent(thumb) +
"&redirect_uri=https://www.facebook.com";
window.open(sharingUrl);
For all parameters we need to use encodeURIComponent, but I try to not use encodeURIComponent for sharingUrl, it still works!
I have a button in my external js file that, when clicked, I want to be sent to a controller that I have. When I have the on click function in JQuery with the url set to my localhost, it works fine, but how do I set it so that it would work similar to the way the base_url works in CodeIgniter, so that it would work in any environment? I've tried using window.location.origin, or window.location.host instead of the localhost, but neither work. Any ideas?
My external JS button:
var html = '<div class="alert alert-success" role="alert"><p class="instruction_text text-center">' + completedText + '</p></div><input id="next_task" class="btn btn-lg btn-default text-center" style="margin-top: 150px; font-weight: bold;" type="button" value="' + text[lang]['continue'] + '"data-url="http://localhost:8888/oda/sample/instructions/' + task_id + '/' + lang + '/' + type + '">';
$('#final_message').append(html);
$(document).on('click', '#next_task', function(e) {
e.preventDefault();
location.href = $(this).data('url');
});
Thanks!
You can leave that work to the browser. If the page is within the same domain you don't need to put it verbosely on your code, you can put something like that:
'"data-url="/oda/sample/instructions/' + task_id + '/' + lang + '/' + type + '"'
note that the / on the beginning says that it will always get to the same place, disregard the current url.
But, if you need for some reason to write the full url window.location.origin will not include the port part of your url, you would have to include window.location.port too to make it work with your environment. and it's not a necessary thing to do in production.
window.location.host should work if you put http:// and / on your string:
'"data-url="http://' + window.location.host + '/oda/sample/instructions/' + task_id + '/' + lang + '/' + type + '"'
You can define base_url value to the JS variable in view and include all external JS below that
Here, I am giving section of example head.php which is located at /your_root/application/views
<script>
var base_url = "<?php echo base_url(); ?>";
</script>