This guide provides some background info on Ajax, and then jumps right in and gets you started with examples. इस गाइड Ajax पर कुछ पृष्ठभूमि जानकारी प्रदान करता है, और फिर सही में कूदता है और तुम हो जाता है उदाहरण के साथ शुरू किया था.
JavaScript has been the main use for XMLHttpRequest objects for a good number of years now, but only recently did it start to gain some “fame”. जावास्क्रिप्ट XMLHttpRequest की वस्तुओं के लिए वर्ष की एक अच्छी संख्या के लिए मुख्य उपयोग रहा है अब, लेकिन हाल ही में था कि यह कुछ प्रसिद्धि "लाभ शुरू." A lot of the ruckus has to do with the many advanced web applications having web developers that see it, drool and want their own site to have those same exact advanced applications/features. हंगामे के एक बहुत बहुत उन्नत वेब वेब डेवलपर्स रहा है कि यह देख, लार और अपनी साइट उन्हीं सटीक उन्नत आवेदन किया है / सुविधाएँ चाहते अनुप्रयोगों के साथ नहीं है. But some of it also has to do with the group of people at AdaptivePath who have named this application Ajax लेकिन यह कुछ भी AdaptivePath पर लोगों के समूह के साथ है जो इस आवेदन Ajax नाम है है
Ajax Beginners: What in the world is Ajax? Ajax शुरुआती: क्या में दुनिया Ajax है?
In a nutshell? संक्षेप में? Well Ajax is a solution to web interfaces. खैर Ajax वेब इंटरफेस के लिए एक समाधान है.
Commonly, the web user enters some data or makes a simple choice, and clicks a button finalizing that choice or data entry and sends the data over to the server. आमतौर पर, वेब उपयोगकर्ता किसी डेटा में प्रवेश करती है या एक आसान विकल्प है, और एक को अंतिम रूप देने कि पसंद या डेटा प्रविष्टि और सर्वर से अधिक डेटा भेजता है बटन क्लिक करता है. The server hastily observes the data and sends back an entire new web page. सर्वर जल्दी डेटा देखने और वापस एक पूरे नए वेब पेज भेजता है. Having to reload a page every time you want to do something is very annoying, disjunctive and extremely time-consuming for the user. को एक पृष्ठ पर हर बार जब आप कुछ करना चाहते हैं पुनः लोड होने बहुत कष्टप्रद है, संधि तोड़नेवाला और बहुत समय उपयोगकर्ता के लिए उपभोक्ता. XMLHttpRequest resurfaces the browser-server interaction to behind the scenes, so the user can just keep on playing with the same page, even while elements on the page are talking to the server! XMLHttpRequest परदे के पीछे के लिए ब्राउज़र-सर्वर संपर्क resurfaces है, तो उपयोगकर्ता के केवल एक ही पृष्ठ के साथ खेल पर रख सकते हैं, जब भी पेज पर तत्वों के सर्वर से बात कर रहे हैं!
With JavaScript we've always been able to server-side script without anything happening in the browser by using a few classic tricks up our sleeves. जावास्क्रिप्ट के साथ हम हमेशा के लिए कर लिया है सर्वर साइड स्क्रिप्ट एक हमारे आस्तीन ऊपर कुछ क्लासिक चाल का उपयोग करके ब्राउज़र में बिना कुछ भी हो रहा है.
Caching form data to a file with JavaScript on a server is good, but this usually doesn't return any useful information to the JavaScript that calls it, so its effectiveness is very limited. एक सर्वर पर जावास्क्रिप्ट के साथ एक फ़ाइल स्वरूप डेटा कैशिंग अच्छा है, लेकिन यह आमतौर पर किसी भी उपयोगी जानकारी जावास्क्रिप्ट है कि यह फोन, तो इसके प्रभाव बहुत सीमित है, पर वापस नहीं करता है. Ajax, however, can get a full parcel of data back from the script it calls. Ajax बहरहाल, डेटा की एक पूरी पार्सल स्क्रिप्ट यह फोन से वापस ले सकते हैं. Hence the “XML” part of the name – which really is just there for looks of sorts, kind of like the “Java” part of JavaScript, because the returned data can be plain text or whatever you like, if XML isn't your preferred choice. "नाम के XML हिस्सा" इसलिए - जो वास्तव में केवल एक तरह का लग रहा है, एक तरह के लिए वहाँ है "जावा स्क्रिप्ट का हिस्सा जावा" की तरह है, क्योंकि लौटा डेटा सादे पाठ किया जा सकता है या जो भी आप चाहें, तो है नहीं XML आपके पसंदीदा पसंद है.
This alone opens up so many exciting possibilities. अकेले यह इतनी कई रोचक संभावनाओं को खोलता है. Every form submission, every JavaScript event, and whatever else application, can now interact with server-side databases and processing power! हर फार्म जमा, हर जावास्क्रिप्ट घटना है, और अनुप्रयोग और जो कुछ भी है, अब सर्वर के साथ बातचीत कर सकते हैं पक्ष डेटाबेस और प्रसंस्करण शक्ति! Data retrieval, password authentication, image generation – you just name it, Ajax can activate it. डेटा पुनः प्राप्ति, पासवर्ड प्रमाणीकरण, छवि पीढ़ी - तुम इसे नाम, Ajax इसे सक्रिय कर सकते हैं.
Putting Ajax Into Practice Ajax अभ्यास में लाना
The only thing that limits Ajax-enhanced web application is your imagination and by browser support. केवल एक चीज है कि सीमा Ajax-बढ़ाकर वेब अनुप्रयोग अपनी कल्पना और ब्राउज़र द्वारा समर्थन नहीं है. Mozilla-based browsers can do it, Safari, and newer versions of Internet Explorer, and Opera 8 but not Opera 7. मोज़िला ब्राउज़र आधारित है, सफारी कर सकते हैं, और इंटरनेट एक्सप्लोरर का नया संस्करण, 7 और 8 ओपेरा ओपेरा नहीं. It's best to slot in an alternative way of doing things for users who aren't as witty as you'd hope for them to be. यह उपयोगकर्ताओं को जो मजाकिया के रूप में के रूप में उम्मीद है कि आप चाहते हैं उनके लिए होना नहीं कर रहे हैं के लिए काम करने का एक वैकल्पिक मार्ग में स्थान के लिए सबसे अच्छा है. Also, Internet Explorer does things somewhat differently (most definitely) from all the other browsers, so it's pretty essential to work the code to account for the irksome 80% of the population who rely on Explorer. इसके अलावा, इंटरनेट एक्सप्लोरर चीजें कुछ अलग ढंग से (सबसे निश्चित रूप से करता है) सभी अन्य ब्रॉउजर में से है, तो यह बहुत से काम कोड आवश्यक है, जो जनसंख्या एक्सप्लोरर पर निर्भर के irksome 80% के लिए खाते.
Now to the exciting part! अब रोमांचक हिस्सा है! Let's generate a straightforward application that can accept input from the user, passes it to some PHP on the server that checks it against a database, and returns the result to the browser in use. चलो एक सरल अनुप्रयोग है कि उपयोगकर्ता इनपुट से स्वीकार कर सकते हैं पैदा, कुछ PHP इसे सर्वर पर भेजता है कि एक डाटाबेस के खिलाफ जाँच करता है, और उपयोग में ब्राउज़र के परिणाम रिटर्न. We assimilate it in three parts. हम इसे तीन भागों में आत्मसात.
First, we need an HTML form. सबसे पहले, हम एक HTML फार्म की आवश्यकता है. As you' can see below: जैसा कि आप नीचे 'देख सकते हैं:
<html> <html> <head> <head> <title>Report</title> <title> रिपोर्ट शीर्षक </> <script type='text/javascript' src='xhr.js'></script> </head> <body> <form action="fallbackpage.php" method="post"> <script type='text/javascript' src='xhr.js'> </ script> </ सिर <form> <body> action="fallbackpage.php" method="post"> <p>Welcome, student. <p> छात्र, आपका स्वागत है. Please enter your essay here:<textarea name="essay" id="essay"> कृपया अपने निबंध यहाँ दर्ज करें: <textarea name="essay" id="essay"> </textarea> <input type="submit" name="submit" value="Submit" onClick="return / textarea> इनपुट <प्रकार <= "नाम" प्रस्तुत = "भेजें" मूल्य = "भेजें" onClick वापस = " grade(this.form.essay.value);"> (this.form.essay.value) ग्रेड; "> </p> </ p> </form> <फार्म /> </body> <शरीर /> </html </ html
Note: For users without proper support for our script ( named xhr.js ), the form will just simply submit to the fallback page at fallbackpage.php . Ok, this is where the JavaScript comes in, we'll take it slow. हमारी कहानी के लिए उचित समर्थन के बिना उपयोगकर्ताओं के लिए नोट: (xhr.js नाम), के फार्म का बस केवल fallbackpage.php पर fallback पृष्ठ पर प्रस्तुत करेंगे. ठीक है, यह वह जगह है जहाँ जावास्क्रिप्ट में आता है, हम लेंगे यह धीमी गति से.
function grade(essay) { समारोह ग्रेड (निबंध) ( The first thing we have to do is initialize the object. पहली बात हम करते है वस्तु इनिशियलाइज़. There are two ways we must do this, for different browsers. वहाँ दो तरीके हमें यह करना होगा रहे हैं, अलग अलग ब्राउज़रों के लिए.
// Mozilla version / / मोज़िला संस्करण if (window.XMLHttpRequest) { (window.XMLHttpRequest) यदि ( xhr = new XMLHttpRequest(); xhr = नई XMLHttpRequest (); } ) // IE version / / IE संस्करण else if (window.ActiveXObject) { और अगर (window.ActiveXObject) ( xhr = new ActiveXObject("Microsoft.XMLHTTP"); xhr = नई ActiveXObject ( "Microsoft.XMLHTTP"); } )
We then escape the user input to make it URL-safe: हम तो उपयोगकर्ता इनपुट से बचने के लिए इसे सुरक्षित बनाने के यूआरएल:
essay=encodeURIComponent(essay); = encodeURIComponent निबंध (निबंध);
and use the open method of the object to open a new connection to the PHP script: और वस्तु की खुली विधि का उपयोग करने PHP स्क्रिप्ट के लिए एक नया संबंध खोलने के लिए:
xhr.open("POST","grade.php"); xhr.open ( "पोस्ट", "grade.php");
The method requires two arguments: first, the HTTP method (GET or POST) ; second, the URL of the script. A quick HTTP header asserts the script for what it's getting, and then the send method conveys the actual request: विधि दो तर्क: पहली आवश्यकता है, HTTP विधि प्राप्त (या पोस्ट); दूसरे, स्क्रिप्ट का URL. एक त्वरित HTTP हैडर कि यह क्या हो रहा है के लिए स्क्रिप्ट का दावा है, और फिर विधि भेज वास्तविक अनुरोध बता देते हैं:
xhr.setRequestHeader( xhr.setRequestHeader ( 'Content-Type', 'सामग्री' प्रकार, 'application/x-www-form-urlencoded; charset=UTF-8'); xhr.send(essay); 'application / x-www फार्म-urlencoded; चारसेट = UTF-8'), (निबंध) xhr.send;
This last step isn't necessary for GET requests, wherein all the data can be contained in the query string of the URL. यह अंतिम कदम अनुरोध जाओ, जिसमें सभी डेटा यूआरएल के क्वेरी स्ट्रिंग में समाहित किया जा सकता है के लिए आवश्यक नहीं है.
Obtaining Final Results अंतिम परिणाम प्राप्त करने के
We're finally ready to see if the HTTP request we made worked. हम अंततः अगर HTTP अनुरोध हम काम किया देखने के लिए तैयार हैं. The readyState property counts up from zero during the request, and shows 4 when the server page has been loaded successfully. ReadyState संपत्ति शून्य से अनुरोध के दौरान मायने रखता है, और 4 से पता चलता है जब सर्वर पृष्ठ सफलतापूर्वक लोड किया गया है.
xhr.onreadystatechange=function() { xhr.onreadystatechange = समारोह () ( if (xhr.readyState==4) { अगर (xhr.readyState == 4) (
If indeed the actual request worked, then we can get the output of the server-side script by querying the responseText property, which contains a string. यदि वास्तव में वास्तविक का अनुरोध किया है, तो हम responseText संपत्ति querying है, जो एक स्ट्रिंग को समाहित द्वारा सर्वर के उत्पादन में साइड स्क्रिप्ट मिल सकती है. For more of a complex server script output, a responseXML property, which can hold a full document object of XML data, is an option also accessible. एक जटिल सर्वर स्क्रिप्ट उत्पादन, एक responseXML संपत्ति है, जो XML डेटा का एक पूरा दस्तावेज़ वस्तु पकड़ कर सकते हो की अधिक जानकारी के लिए, एक भी सुलभ विकल्प है.
grade = xhr.responseText; ग्रेड xhr.responseText =; alert ("Nice essay. Your grade is " + grade); चेतावनी ( "अच्छा निबंध. आपका ग्रेड + है" ग्रेड); } ) return false; वापसी झूठी; } )
In conclusion, the third component consist of PHP script, which basically lives on the server and waits patiently for the JavaScript to pass it some juicy data so it can thrive. अंत में, तीसरे घटक PHP स्क्रिप्ट है, जो मूल रूप से सर्वर पर रहता है और जावास्क्रिप्ट के लिए धैर्यपूर्वक इंतजार से मिलकर बनता है इसे कुछ रसदार डेटा से गुजारें तो यह कामयाब होना कर सकते हैं. This example uses some PHP, but any language you like — Ruby, Perl, C, ASP — can address your needs as well. इस उदाहरण में कुछ PHP का उपयोग करता है, लेकिन किसी भी भाषा तुम जैसे - रूबी, पर्ल, सी, एएसपी - आपकी आवश्यकताओं के पते के रूप में अच्छी तरह से कर सकते हैं. The core of this example script is a natural-language function called grade_essay() that grades student essays from 1 to 100, but I will redact that part to conserve space. यह उदाहरण लिपि के मूल एक प्राकृतिक भाषा समारोह grade_essay कहा जाता है () है कि ग्रेड 1 से छात्र निबंध के लिए 100, पर मैं उस भाग को संपादित करना अंतरिक्ष संरक्षण होगा.
<?php <? php? function grade_essay($essay) { समारोह grade_essay $ (निबंध) ( return strlen($essay); वापस strlen ($ निबंध); } ) $essay = urldecode(implode(file('php://input'))); $ निबंध = फटना urldecode (( '(php फ़ाइल: / / इनपुट'))); $grade = grade_essay($essay); $ ग्रेड = grade_essay $ (निबंध); echo $grade; $ ग्रेड गूंज; ?> ?>
The php://input grabs the POST data, which gets put into a string, decoded and passed to the clever grading algorithm. Php: / / इनपुट पकड़ लेता है पोस्ट डेटा है, जो एक स्ट्रिंग, डीकोड में डाल दिया और चालाक ग्रेडिंग एल्गोरिथ्म को पारित हो जाता है. The algorithm returns a numeric grade. एल्गोरिथ्म एक अंकीय ग्रेड आए. Lastly, we just output the grade with echo - ordinarily, this would display in the browser, but since the PHP script is running “behind the scenes,” the string output is simply returned to the JavaScript that called it. अंत में, हम सिर्फ उत्पादन गूंज के साथ ग्रेड - आमतौर पर, यह ब्राउज़र में प्रदर्शित है, पर होगा क्योंकि PHP स्क्रिप्ट 'परदे के पीछे चल रहा है, "स्ट्रिंग उत्पादन केवल जावास्क्रिप्ट है कि यह फोन को लौट रहा है. If you need structured data, an XML document would be output with an echo statement in just the same way, but the content-type of the output page basically must be set to text/xml . यदि आप डेटा, एक XML दस्तावेज़ की संरचना की जरूरत है तो बस एक ही रास्ते में एक बयान गूंज के साथ उत्पादन होगा, लेकिन सामग्री उत्पादन पृष्ठ के प्रकार का मूल पाठ को सेट किया जाना चाहिए / xml.
What the user sees is this: She/He types their essay into the text area in the browser, clicks Submit, and within instants an alert box pops up giving him/her a final grade on the essay. क्या उपयोगकर्ता देखता है यह है, वह / वह पाठ क्षेत्र में ब्राउज़र में उनके निबंध प्रकार, भेजें क्लिक करता है, और instants के भीतर एक चेतावनी बॉक्स को हलका उसे दे / उसे निबंध पर एक अंतिम ग्रेड. Invisibly, the essay has been sent to the server, read and evaluated by a team of PHP elves, and inevitably returned with a grade, without ever having to reload the page. Invisibly, निबंध सर्वर, पढ़ने के लिए भेज दिया गया है और PHP कल्पित बौने के एक दल द्वारा मूल्यांकन, और अनिवार्य रूप से एक अंक के साथ लौट आए, कभी पृष्ठ पुनः लोड बिना. The user can modify her essay and resubmit it continuously. उपयोगकर्ता उसे निबंध संशोधित करने और उसे लगातार फिर से जमा कर सकते हैं.
And that's the general substance of the almost magical XMLHttpRequest object! और वह लगभग जादुई XMLHttpRequest वस्तु के सामान्य पदार्थ है! The example is pretty simple and straight forward, but the uses of the object can be highly, multi clever . उदाहरण के सुंदर और सरल है सीधे आगे है, लेकिन वस्तु के अत्यधिक उपयोग करता है, बहु चालाक हो सकता है.
For further inspiration and great examples of ingenious Ajax applications you can momentarily steer away from SimpleHelp.Net and visit आगे की प्रेरणा और सरल Ajax अनुप्रयोगों के महान उदाहरण के लिए आप क्षण भर के SimpleHelp.Net और यात्रा से दूर बधिया कर सकते हैं iGoogle iGoogle , , Pageflakes Pageflakes , , Netflix Netflix and और Netvibes Netvibes . .
However, the data and functions that Ajax sends and acts out is simply up to you. हालाँकि, डेटा और कार्यों कि Ajax भेजता है और सिर्फ आप पर निर्भर करता है.























Qui a fait le texte en français ?…… एक संपन्न Qui Français le texte en? ... ...
french or chinese translation ?….. फ्रेंच या चीनी अनुवाद ...? ..