{"id":20270192,"url":"https://github.com/lukas-stuehrk/xmlhttprequest","last_synced_at":"2025-04-11T04:02:02.595Z","repository":{"id":27742910,"uuid":"31230748","full_name":"Lukas-Stuehrk/XMLHTTPRequest","owner":"Lukas-Stuehrk","description":"An implementation of the JavaScript XMLHTTPRequest object to extend JavaScriptCore.","archived":false,"fork":false,"pushed_at":"2017-12-19T18:50:26.000Z","size":24,"stargazers_count":66,"open_issues_count":1,"forks_count":14,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-04-27T02:22:27.984Z","etag":null,"topics":["ios","javascriptcore","objective-c","xmlhttprequest"],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Lukas-Stuehrk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-02-23T21:27:42.000Z","updated_at":"2024-02-12T12:00:01.000Z","dependencies_parsed_at":"2022-09-03T03:00:48.562Z","dependency_job_id":null,"html_url":"https://github.com/Lukas-Stuehrk/XMLHTTPRequest","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lukas-Stuehrk%2FXMLHTTPRequest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lukas-Stuehrk%2FXMLHTTPRequest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lukas-Stuehrk%2FXMLHTTPRequest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lukas-Stuehrk%2FXMLHTTPRequest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Lukas-Stuehrk","download_url":"https://codeload.github.com/Lukas-Stuehrk/XMLHTTPRequest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248339253,"owners_count":21087214,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","javascriptcore","objective-c","xmlhttprequest"],"created_at":"2024-11-14T12:29:13.814Z","updated_at":"2025-04-11T04:02:02.533Z","avatar_url":"https://github.com/Lukas-Stuehrk.png","language":"Objective-C","readme":"# XMLHTTPRequest\n\nIn iOS 7, Apple introduced the possibility to [execute JavaScript via the JavaScriptCore JavaScript \nengine] (http://nshipster.com/javascriptcore/). Unfortunately, JavaScriptCore is missing some \nobjects and functions a JavaScript environment of a browser would have. Especially the\n`XMLHttpRequest` (see the [Mozilla documentation]\n(https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) object needed for AJAX requests\nis not provided by JavaScriptCore. This library implements this missing object, so it is possible to \nuse JavaScript libraries which were originally developed for in-browser use in your Objective-C \n(or Swift) application without the need to use a hidden WebView.\n \n \n## Provided functions\nThis library tries to implement the full XMLHttpRequest specification. Currently not all\nfunctionality is implemented yet. The current limitations are:\n\n* Synchronous calls are not supported.\n* The `onload` and `onerror` callbacks are currently not supported.\n* The `upload` callback is currently not supported.\n* The `timeout` property is currently not supported.\n\nIt is planned to support all functionality of the HTML5 specification at some point.\n\n## How to use it\nCreate a new instance of the `XMLHTTPRequest` class. Then call the `extend:` method and pass either\na `JSContext` instance or a `JSValue` instance. The given object will be extend with the \n`XMLHTTPRequest` object.\n \n```objc\n#import \u003cXMLHTTPRequest/XMLHTTPRequest.h\u003e\n\n...\n\nJSContext *jsContext = [JSContext new];\nXMLHttpRequest *xmlHttpRequest = [XMLHttpRequest new];\n[xmlHttpRequest extend:jsContext];\n```\n\nThe JavaScript context now has a XMLHTTPRequest object you can use like the object found in\nbrowsers. Example (JavaScript):\n\n```JavaScript\nrequest.open('GET', 'http://example.com');\nrequest.setRequestHeader('Accept', 'text/html');\nrequest.setRequestHeader('X-Foo', 'bar');\nrequest.send();\n```\n\n### More Stuff\n\nIf you are interested in more polyfills for missing browser functionality in JavaScriptCore, there is\na window timers implementation (`setTimeout`, `setInterval`, ...) called [WindowTimers]\n(https://github.com/Lukas-Stuehrk/WindowTimers).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukas-stuehrk%2Fxmlhttprequest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukas-stuehrk%2Fxmlhttprequest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukas-stuehrk%2Fxmlhttprequest/lists"}