javascript - XMLHttpRequest doesn't work asynchronously -


यह मेरा JS

  var req = new XMLHttpRequest (); req.open ( 'पोस्ट', '/ कुछ-स्थान', true); Req.send ("सर्वर-पक्ष संसाधित करने के लिए एक स्ट्रिंग"); Var resp = req.responseText;  

समस्या यह है कि यह काम नहीं करती। जब भी मैं प्रतिक्रिया देखने के लिए console.log (resp) का उपयोग करता हूं, यह एक खाली स्ट्रिंग है।

लेकिन जब मैं दूसरी पंक्ति को req.open ('POST', '/ some-location', गलत) में परिवर्तित कर देता हूं; , resp संसाधित परिणाम मैं async को झूठे में सेट नहीं करना चाहता, हालांकि।

क्या मुझे यह देखकर एक योजना जावास्क्रिप्ट है कि मैं क्या गलत कर रहा हूं?

यह काम नहीं करता क्योंकि यह एक AJAX अनुरोध नहीं है आपको AJAX का उपयोग करना चाहिए यह बहुत जटिल नहीं है और आप

पर निर्देश पा सकते हैं।


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

asp.net mvc - How to attach sql database to a javascript graph -

c# - How to know the number of Threads created and limit the Tasks accordingly -