forked from GitHub/gf-core
allow specifying content-type in ajax_http
This commit is contained in:
@@ -89,7 +89,7 @@ function GetXmlHttpObject(handler)
|
|||||||
return objXMLHttp
|
return objXMLHttp
|
||||||
}
|
}
|
||||||
|
|
||||||
function ajax_http(method,url,body,callback,errorcallback) {
|
function ajax_http(method,url,body,contenttype,callback,errorcallback) {
|
||||||
var http=GetXmlHttpObject()
|
var http=GetXmlHttpObject()
|
||||||
if (!http) {
|
if (!http) {
|
||||||
var errortext="Browser does not support HTTP Request";
|
var errortext="Browser does not support HTTP Request";
|
||||||
@@ -109,17 +109,20 @@ function ajax_http(method,url,body,callback,errorcallback) {
|
|||||||
}
|
}
|
||||||
http.onreadystatechange=statechange;
|
http.onreadystatechange=statechange;
|
||||||
http.open(method,url,true)
|
http.open(method,url,true)
|
||||||
|
if (contenttype != null) {
|
||||||
|
http.setRequestHeader("Content-Type", contenttype)
|
||||||
|
}
|
||||||
http.send(body)
|
http.send(body)
|
||||||
}
|
}
|
||||||
return http
|
return http
|
||||||
}
|
}
|
||||||
|
|
||||||
function ajax_http_get(url,callback,errorcallback) {
|
function ajax_http_get(url,callback,errorcallback) {
|
||||||
ajax_http("GET",url,null,callback,errorcallback)
|
ajax_http("GET",url,null,null,callback,errorcallback)
|
||||||
}
|
}
|
||||||
|
|
||||||
function ajax_http_post(url,formdata,callback,errorcallback) {
|
function ajax_http_post(url,formdata,callback,errorcallback) {
|
||||||
ajax_http("POST",url,formdata,callback,errorcallback)
|
ajax_http("POST",url,formdata,null,callback,errorcallback)
|
||||||
// See https://developer.mozilla.org/En/XMLHttpRequest/Using_XMLHttpRequest#Using_FormData_objects
|
// See https://developer.mozilla.org/En/XMLHttpRequest/Using_XMLHttpRequest#Using_FormData_objects
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user