Get parameter from another page using javascript? - javascript

I have a wordpress site, and i'm not a php developer and not very eager to start either so I'm avoiding it like the plague, but I do have a requirement that requires a little bit of extra coding. I need to:
go to a different website,
download that page,
check for a certain phrase,
if phrase exists, extract a link from that page
and if link is returned I need to show that link on my wordpress site.
Currently, I have an asp.net page that does this and i'm hosting that page in an iframe on my wordpress site. but i'd like to do it without an iframe.
Question is, is there anyway for javascript to go to a different page (my asp.net page) and get a parameter (link) from it. If link is provided i will show certain content on wordpress site.
Or can javascript download a text file from the server? problem with that is i need a trigger to update the text file.
Any advice is appreciated.
Thanks.

What you should understand is that by "avoiding [PHP] like the plague" you're inadvertently avoiding the proper way of doing things. Javascript is a client-side language, and PHP is a server-side language. By asserting that you only want the load on the client's end (the kind of logic involved in what you want to do isn't exactly lightweight), you can potentially end up with a VERY slow webpage.
Not to mention, this type of situation is analogous to using a hammer to do a backhoe's job.
Either way, to answer your question, yes. You can use the jQuery Load method in tandem with Javascript's Match method.
What you should TRY to do, however, is make a CURL request using PHP, and then cache the page on your server. By doing this, you will limit the number of calls to a given page, and optimize load times.
Please consider the second option, even as an attempt in good practice. Good luck.

Use ajax and connect to a different page (on your server) which is written in server-sided language (like asp.net, as you said), that connects to the remote website.
More about Ajax

Related

Use services of a different page without displaying it

I have a web page A created by a PHP script which would need to use a service only available on another page B – and for various reasons, A and B can't be merged. In this particular instance, page A is a non-WordPress page and page B is WordPress-generated. And the service in question is sending emails in a specific format which is supplied by a WP plugin.
My idea is to use page A to generate the email content and then send that content to page B which then, aided by the plugin, sends the email in the appropriate format and transfers control back to page A. This would be perfectly doable – but what I would like in addition is for page B never to be displayed. The visitor should have the impression that they are dealing only with page A all the time. Can that be done and if so, how?
I do not intend this to be a WordPress question (although maybe it is), rather more generally about using another page's script in passing without displaying that other page.
If you do have source access, it would be most reliable to use the addon directly... But if you cannot, the second easiest would be to use curl to mimic the form post on page B. This would happen server side so the user wouldn't see it happening.
To figure out what you need to send in your POST request, open your browser's developer tools and watch the network tab when you send the form manually, take the URL, and all the post data. Then you'll be able to mimic it.
You may proxy https://SITEA.com/siteB/whatever to http://SITEB.com/whatever - or the other way around... I didn't fully understand the process :P
In case you just want the siteB service call, you may also send the requests via curl or a HTTP library of your choice - which might be better as you will have to get a nonce first and stuff like that.

Tracking Web Page using java,JS,Jquery,AJAX

I am fresher in this tracking web page topic.
I want to be write code for tracking web page and if is any changes have occurred in that page then it is able to automatic mail sending to my mail id.
Is it possible?
If yes then which programming language is best for it?
would you please give me suggestion that which technology I have used for this?
Which are prerequisites for it?
How do I've start and from where?
Give me basic example also.
Which programming languages do you already know? Take the one you know the best!
Just to give an idea how to approach it:
use a Library similar to jQuery (jquery, jsoup, beautifulsoup, etc…) to extract specific page elements
save the element's content somewhere (database, file)
run the script periodically
compare saved content with fresh content from the website
send a mail if a change happened

Prepopulating an ASP form without code behind from standard HTML page

I've been given a task, which I believe my employer is just putting a carrot in front of me and seeing how far I will run.
A vendor has provided us with a form application. This application is in ASP. My task is to see if its possible to Pre-populate this ASP application because we want to host a little 'mini-wizard' questionnaire on our site and when you click submit on the 'mini-wizard' it pre-populates a few fields on the application.
My first question to him was "Do we have access to the ASP code behind to look for parameters passed via Get/Post. - NO
I thought, ok, so there is no way to do it. He then said you may be able to do it with javascript. Which I could see if I could put JS on the application page, but I can't do that either.
My final idea would be to make an ajax call for that page, modify the contents and then display it on our site. I am not sure that would even work, have never tried making an AJAX call to an ASP page from a non-asp site.
Can it be done or is this some form of new developer hazing?
Yes it can be done. As you are going to use client side ajax, the page will give you nothing but the HTML output of that page. So you just need to know that what parameters you need to pass to that page. Even there might be no need to pass parameters.So, Take an asp page of your own and do the ajax call

call live webservice from simple html page...?

I read lots of post here, but don't get specific answer.
I have live server on which I have my web services work properly.
now, I want to create one simple html page through which I call that web service.
with javascript this is possible but what is exact.
I repeat again only html and javascript through which I want to call that web service.
you can use jquery to load the data from webservice, but you might need to include jquery js file and your browser(IE) might prompt for security violation and you might need to click yes.

save entere webpage using ruby (clojure or javascript)

I've got a problem. I'm working with a food supplier and I need save the content of each order as html. Orders are listed on a single page as links, but this has 2 difficulties
Page uses authentication (need to log me in in advance)
This is the real problem: the page use a lot of javascript. Actually everything works without changing the web address so I can't use wget or rio gem (url not like www.fooddoe.com/order, www.fooddoe.com/order/1, etc. but always like www.fooddoe.com/suplierx).
I think firewatir would be a good option but the problem is than I need to save the page in a format similar to html (including images). Is it possible using firewatir? Are there other options in clojure or javascript?
Thanks so much!!
I had to read your question twice to understand what you mean.
From web address from example I assume this is yours supplier web page. So IMHO the easiest way is:
Look into source of web page to get an idea how it gets the data (99% for some kind of AJAX request).
Request goes to the server which responds to it.
Now there are two ways:
Get idea how the request is made and write and app to make such request and generate web page with it (more difficult, more general)
Contact your supplier and get original database (simpler but one-time solution)
And I think that this is not the question specific to any language.

Categories

Resources