GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Ehlster/XMLHTTPRequest: An implementation of the JavaScript XMLHTTPRequest object to extend JavaScriptCore.

BranchesTags
Open more actions menu

Latest commit

 

History

13 Commits
13 Commits

Folders and files

NameName
Last commit message
Last commit date
XMLHTTPRequest.xcodeproj
XMLHTTPRequest.xcodeproj
 
 
XMLHTTPRequest.xcworkspace
XMLHTTPRequest.xcworkspace
 
 
XMLHTTPRequest
XMLHTTPRequest
 
 
XMLHTTPRequestTests
XMLHTTPRequestTests
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
Podfile
Podfile
 
 
README.md
README.md
 
 
XMLHTTPRequest.podspec
XMLHTTPRequest.podspec
 
 

Repository files navigation

XMLHTTPRequest

In iOS 7, Apple introduced the possibility to [execute JavaScript via the JavaScriptCore JavaScript engine] (http://nshipster.com/javascriptcore/). Unfortunately, JavaScriptCore is missing some objects and functions a JavaScript environment of a browser would have. Especially the XMLHttpRequest (see the [Mozilla documentation] (https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) object needed for AJAX requests is not provided by JavaScriptCore. This library implements this missing object, so it is possible to use JavaScript libraries which were originally developed for in-browser use in your Objective-C (or Swift) application without the need to use a hidden WebView.

Provided functions

This library tries to implement the full XMLHttpRequest specification. Currently not all functionality is implemented yet. The current limitations are:

  • Synchronous calls are not supported.
  • The onload and onerror callbacks are currently not supported.
  • The upload callback is currently not supported.
  • The timeout property is currently not supported.

It is planned to support all functionality of the HTML5 specification at some point.

How to use it

Create a new instance of the XMLHTTPRequest class. Then call the extend: method and pass either a JSContext instance or a JSValue instance. The given object will be extend with the XMLHTTPRequest object.

#import <XMLHTTPRequest/XMLHTTPRequest.h>

...

JSContext *jsContext = [JSContext new];
XMLHttpRequest *xmlHttpRequest = [XMLHttpRequest new];
[xmlHttpRequest extend:jsContext];

The JavaScript context now has a XMLHTTPRequest object you can use like the object found in browsers. Example (JavaScript):

request.open('GET', 'http://example.com');
request.setRequestHeader('Accept', 'text/html');
request.setRequestHeader('X-Foo', 'bar');
request.send();

More Stuff

If you are interested in more polyfills for missing browser functionality in JavaScriptCore, there is a window timers implementation (setTimeout, setInterval, ...) called [WindowTimers] (https://github.com/Lukas-Stuehrk/WindowTimers).

About

An implementation of the JavaScript XMLHTTPRequest object to extend JavaScriptCore.

Topics

iosjavascriptcoreobjective-cxmlhttprequest

Resources

Readme
MIT license
Activity

Stars

70 stars

Watchers

7 watching

Forks

13 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.