I will try to explain what I need. I am using API of some website that sends message to phone number. When user writes his phone number into the form of my website, the data is sent to another website. I want the data to be sent without opening new window or link. Is it possible? Let the link be "example.com?number=123456789".
Have you tried using AJAX technology?
AJAX is a developers dream, because you can: Update a web page
without reloading the page Request data from a server - after the
page has loaded Receive data from a server - after the page has
loaded Send data to a server - in the background
http://www.w3schools.com/ajax/
Related
I'm trying to create an interactive web shell that will let you connect and perform actions in a different website using post requests but I also want the shell to update live (this is the "interactive" part).
I came across Keeping session alive with Curl and PHP and W3School PHP & AJAX but can I blend them together? is it possible to maintain a session with ajax? if not, what should I use to do this project?
EDIT:
To make things more clear, What I'm trying to do is:
Go to my website
Put my credentials to google and click a button
background php sends a post request to google's login page with my credentials
I see in my website a Login succeeded alert using ajax
click a button on my website that will retrieve the content of the first email in my mail dir
send a get request to gmail with php and return the data with ajax
Will it work? In 6 I need a live session to view the page and I'm creating the session on step 3, How do I keep the session alive?
We are making a app with php in which we want to push data to client browser same in the way in which facebook notificaiton sent by facebook. i know about commet and also have used ajax in past but ajax is not efficeint while commet programing is out of my mind.
Sample can seen at ESPNCRICINFO.COM live scorecard which is automatically pushed
by server to brwoser and than append to document without refreshing. Same app we
have to made.
Simply i need to build some code that send data to all the browser which have our webpage opened. No restrictions. Just need to send to all. So there is no need to check to whom data will be push.
I really need it urgently.
can you use JavaScript setTimeout(function name, seconds) ?
In JavaScript function you can generate .post request for some PHP script which can load messages, when the message will load, you can show it via you JavaScript. the timer will call this function for all people.
I want to receive the post request on a web page while my page isn't refreshing or is still or just open, sort of concept like dynamic messages without refreshing the page. I don't want to pull it using ajax
I tried sending request to that URL but that doesn't work. I wanted to know a way to receive a post data and display it to user.
Any help is appreciated.
I read about amazon sns push for http/s, but they too doesn't send request to each browser page. they just send the request to the server, how should i make things in a way that , that post request from amazon goes to every browser page wherever it is open and display the content in the post message.
Maybe you are looking for WebSocket? It is basically a protocol used to send information from server to client without the need for the client to make a request. Similar to what chats systems like facebook messenger use, it stops the client having to poll a server for data.
Context:
There is an asp page in another web site that contains a search form. After submitting this form with the search value, the page displays the results of the search in an iframe.
Question:
I want to use the returned result in my page without loading that page in browser. I have got permission from the other web site administrator. I know php and jQuery. How should I proceed?
Example:
abcd.asp contains a form which contains <input name="regno"/> and a submit button. The form submits to itself and results Name, date of birth and Marks is returned in table format in an iframe.
Notes:
I have a page with same <input> and upon submitting it will use the above asp page and get details and display it in my page.
Easiest way:
Use jQuery to submit your page via AJAX to a local PHP file.
When the local PHP file gets the request, do a curl post request to your remote page and fetch the results.
Return these results in your local PHP script so that these will be available to your AJAX request
Your ajax request now has the remote contents, so just use jQuery to push them into the document.
You should use AJAX to perform this task. It loads a particular section of data without reloading a page. More info about what is ajax is here
Your best option is to use jQuery's ajax method. To make this work with different domains you need to enable crossdomain support. This is very easy in jQuery:
$.support.cors = true; // enable cross domain support
Now you can make a request to another domain. Of course the server on that domain must also accept cross-domain requests. ;)
Option 1 - HTTP GET & JSONP
As Twisted1919 pointed out you have to use jsonp if you want to make a HTTP GET request. If you're not familiar with jsonp It requires a bit of reading to understand the concept. But there is excellent support for this in jQuery (as described in jQuery.ajax()).
Option 2 - HTTP POST
If you're using http post to make your request you can simply use jQuery.post() for this. With cros domain enabled an the server accepting your request this should work out of the box.
I need to configure TWILIO SMS account to forward the received SMS to some PHP URL. So,
now if I have that PHP URL already opened in my web browser, and if some message is being forwarded to this URL from TWILIO with GET request, how can I show the received data in that already opened PHP Web URL?
Ex : If I give this URL http://www.somephp.com/index.php in TWILIO dashboard to forward the incoming SMS with GET request.
And I open that in my web browser already to see if there is any SMS from TWILIO. How can I constantly check if any new SMS forwarded from TWILIO?
Can I use any TIMER to check GET requests ? Or Am I totally in wrong way? I cannot find any solution around when I google. Please forgive me if it seems to be a silly question. I would be very grateful if you could guide me in this issue. Thanks a lot for your time!
For easy you can use the jQuery library, then poll regularly for new data using a backend php script.
You'd have to use some JavaScript (jQuery might be easier) to run a setInterval function every X seconds. Anther option is you could use a meta-refresh that would simply reload the page every X seconds.
I dont think that way its possible to achieve what you want.
What you can do is -
set http://www.somephp.com/index.php as sms reply in you dashboard.
In index.php save any new request into a database with sender details and message content and time it was received.
Now write a new script say http://www.somephp.com/updateMessages.php
In this page use jquery or javascript to make AJAX request to a script which will connect to database and check if there are any new messages. If there is, display that message and start checking for a message received after this message.
This way if you will open http://www.somephp.com/updateMessages.php you will get all new messages here.