How to check whether a port is open at client’s network/firewall?

Gotcha !!! I have solved my problem with JSONP and jQuery AJAX call. I discovered the timeout attribute of jQuery AJAX and my code executed fluently when the port was blocked or opened. Here is the solution for future visitors. Thanks to all answerers for contribution. <!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”> <html> … Read more

JSON string to JS object

Some modern browsers have support for parsing JSON into a native object: var var1 = ‘{“cols”: [{“i” ……. 66}]}’; var result = JSON.parse(var1); For the browsers that don’t support it, you can download json2.js from json.org for safe parsing of a JSON object. The script will check for native JSON support and if it doesn’t … Read more

Callback function for JSONP with jQuery AJAX

This is what I do on mine $(document).ready(function() { if ($(‘#userForm’).valid()) { var formData = $(“#userForm”).serializeArray(); $.ajax({ url: ‘http://www.example.com/user/’ + $(‘#Id’).val() + ‘?callback=?’, type: “GET”, data: formData, dataType: “jsonp”, jsonpCallback: “localJsonpCallback” }); }); function localJsonpCallback(json) { if (!json.Error) { $(‘#resultForm’).submit(); } else { $(‘#loading’).hide(); $(‘#userForm’).show(); alert(json.Message); } }

Does Wikipedia API support CORS or only JSONP available?

To make JavaScript Fetch/XHR requests to Wikipedia, add origin=* to the URL query params. So the base of the URL in the question should be like this: https://en.wikipedia.org/w/api.php?origin=*&action=query… See the CORS-related docs for the Wikipedia backend: For anonymous requests, origin query string parameter can be set to * which will allow requests from anywhere. 2016-05-09 … Read more

How to natively enable JSONP for existing WCF service?

Update your config to look like: <configuration> <system.web> <compilation debug=”true” targetframework=”4.0″> <authentication mode=”None”> </authentication></compilation></system.web> <system.webserver> <modules runallmanagedmodulesforallrequests=”true”> </modules></system.webserver> <system.servicemodel> <servicehostingenvironment **aspnetcompatibilityenabled**=”true”> <standardendpoints> <webscriptendpoint> <standardendpoint **crossdomainscriptaccessenabled**=”true” name=””> </standardendpoint></webscriptendpoint> </standardendpoints> </servicehostingenvironment></system.servicemodel> </configuration> See here for a blog post providing a walkthrough of creating a wcf service that’s accessible cross-domain. This will enable your service to accept requests … Read more

WCF error : 405 Method Not Allowed

You need to use JSONP for a cross-domain call to get round the browser restrictions, and to update your web.config with crossDomainScriptAccessEnabled set to true to get round server ones. There’s a good example in the answer here: how to avoid cross domain policy in jquery ajax for consuming wcf service? You may also have … Read more