![]() If you want to test the function on your PC locally, restart your browser with the following command (supported by all browsers except safari): yournavigator. Accept: text/plain, text/html Accept: text/x-dvi q.8 mxb100000 mxt5.0, text/x-c Wildcards In order to save time, and also allow clients to receive content types of which they may not be aware, an asterisk '' may be used in place of either the second half of the content-type value, or both halves. It's just a small gift to contibute to the group. One solution supporting older browsers: function httpRequest() ) Var info = eval ( "(" + xmlHttp.responseText + ")" ) ĭocument.getElementById( "TextBoxCustomerName" ).value = ĭocument.getElementById( "TextBoxCustomerAddress" ).value = 1 If ( xmlHttp.responseText = "Not found" )ĭocument.getElementById( "TextBoxCustomerName" ).value = "Not found" ĭocument.getElementById( "TextBoxCustomerAddress" ).value = "" If ( xmlHttp.readyState = 4 & xmlHttp.status = 200 ) ![]() XmlHttp.onreadystatechange = ProcessRequest Var Url = "GetCustomerInfoAsJson.aspx?number=" + CustomerNumber Var CustomerNumber = document.getElementById( "TextBoxCustomerNumber" ).value In the case below, an ASPX page (that's servicing as a poor man's REST service) is being called to return a JavaScript JSON object. But, as previously mentioned, you'd be much better off with a JavaScript library. If (this.readyState = 4 & this.Here is code to do it directly with JavaScript. From the select list, choose JSON instead of Text It is imperative that you send valid JSON. Xhttp.open("POST", "ajaxfile.php", true) To send a POST request with JSON, select the POST request method, click on Body, and select raw. If (this.readyState = 4 & this.status = 200) tRequestHeader('Content-type', 'application/x-www-form-urlencoded') Xhttp.open("GET", "ajaxfile.php?request=1", true)
0 Comments
Leave a Reply. |