sending data to server with javascript - javascript

how can i send a string value to a sever with java script without submit method?
i know i can use jquery or ajax but is there any other way to do that without any library?
i searched in Google and i find some good links:
How to send data to remote server using Javascript
http://bytes.com/topic/html-css/answers/154271-post-data-server-javascript-client-side
but all of them said we should use jquery or ajax

AJAX isn't a library - it's built into Javascript, and is available on pretty much all browsers from even IE6 onwards.
You can find full tutorials and instruction here: https://www.w3schools.com/js/js_ajax_intro.asp

Yes, that what you have to do if you don't want to refresh the page. Although, you could find other framework rather than jQuery. That framework still use ajax technology inside.

Related

Writing data to a local file using HTML5 and Javascript in Chrome

I have created an interactive quiz using html and javascript which will be run on a touchscreen at an event and I need to write the results to a local csv file (so no internet connection). It needs to write to an already existing file, so it cannot be done where the data is stored locally and a download link is generated through the browser.
How would I go about doing this? All methods I have found are either unreliable or no longer supported. The browser I am using is Chrome, so it does not need to be cross-browser compatible.
Can anybody help or point me in the right direction please?
Install a web server.
Point the browser at http://localhost.
Send the data to the server using Ajax or a form submission.
Process the data (including storing it in a file) using the server side language of your choice.
When javascript is used only in the client-side cannot write data as you want.
Follow the #Quentin recommendation about install some web server, as apache using php for instance(It is pretty straight forward!). I also recommend you to create restFull methods to do it with jquery calls from the client side, it is easy to find many examples in the internet and quicky...
If you want something more easy you could work with html post using forms in php, the most easy way to do it.

Check if a certain string exists on a AngularJS web page by using php

I saw this answer Check if string exists in a web page - Check if string exists in a web page and it works
but what about checking for a string on an external web page that is using Angularjs? Is it still possible to search with php curl or another language should be used.
The simple answer is no, because the problem is that AngularJS is a clientside SPA framework. You would need to parse the JS and run it like a browser would, in order to determine the content of the page. I don't know of any PHP libs that do this.
The alternative without "just php" would be to use a web crawler. There are a couple out there that solve this exact problem. You could then technically use PHP to read the output of the webcrawler program. But then you might not need PHP at all...
If you're going to do any sort of serious page reading I would just use a web crawler/browser to do this. Why reinvent the wheel(browser) when you can just use it?

Using asp.net ajax client side framework on a bare-bones HTML page

I want to use the asp.net ajax client side framework on a bare-bones HTML page. Firstly, is it possible? If yes, then can someone point me in the right direction?
Yes, it is possible. You need to include MicrosoftAjax.js and start using it. For further reference you can check the following links:
Microsoft Ajax Client Reference
Using Microsoft Ajax with PHP
In a word you need to include the file and start using the API. What exactly do you need from ASP.NET Ajax? Have you considered using jQuery instead? My experience tells that ASP.NET Ajax is suitable for ASP.NET only cases (web-forms, server controls, partial rendering etc) whereas jQuery is more close to the metal and works with all server platforms.

file upload using ajax

I am looking for an AJAX method that can be used to file upload.
It will be super if I find a function that uses Prototype + Script.acul.us
File uploads are not possible using pure Ajax, because Javascript can't get direct access to the local file.
Tools like the jQuery form plugin work around this by generating an invisible iframe on the fly, and submitting to that.
There probably is a Prototype based, or framework independent solution for this as well.
there is no native ajax support for this, however Uploadify does a workaround using flash (uses jquery but is able to be used with other api's since 2.0)
http://teamco-anthill.blogspot.com/2009/01/ajax-progress-indicator-with-prototype.html
?
As others have pointed out, javascript is not able to asynchronously upload files (otherwise javascript enabled sites could steal any file off your harddrive). The best approaches are:
A flash uploader, as already suggested
Or simulate an Ajax request using an iframe
The iframe approach means that it's the iframe which reloads, instead of the page displayed to your users, so that to the end user, the experience looks as if it's Ajax.
If you're using rails, which I gather you might be due to using prototype and scriptaculous, there's a plugin available which handles the tricky bits of this approach for you called responds_to_parent, It's been ages since I implemented this in a rails app myself, but step 6 from this blog looks like a good example of how to use it.

a javascript message from a servlet

how could i display a javascript message from a servlet.
I am searching examples
thanks for help.
that's a bit confusing: servlet is a server-side technology. JavaScript is working at the client-side (or you have a JS server?). You probably want to use AJAX to display a result of a servlet. I suggest you trying out jQuery.
You can check out this question as well on SO: How to learn AJAX using jQuery in a Java web app

Categories