dataType: json or html. Depende kung unsay ei reply sa service.
contentType: application/json if ang data ako gi send kay JSON otherwise dili nako ei specify.
dataType: json or html. Depende kung unsay ei reply sa service.
contentType: application/json if ang data ako gi send kay JSON otherwise dili nako ei specify.
I tried jsonp para cross domain gali problem is ang response nya text/html dle match sa ako contentType nga application/json. Akong url is kato nga page sa API nila murag mao sguro nga ang UI ang gi response kay mao man akong url. Ang function siguro ako tawgon, problem is asa man sad naq tawgon ang function?
Can you share some code? ei mask lang ang mga dili angay ipa kita.
mao ni siya ayy
<script>
$(document).ready(function() {
$.ajax({
url: 'urlnisaauthenticatesessionpagesaapi/json?callback?username=sample&password=sample',
type: "POST",
dataType: 'jsonp',
contentType: 'application/javascript',
success: function(msg) {
alert(msg);
console.log(msg);
}
});
});
</script>
better check the api first.. you basically need to know these 3 things: (1) URL (2) method (post/get/delete/put), although first 2 pa ang supported by ajax (3) the type of response (json/html/etc).. jsonp is by default for cross-domain requests..
- - - Updated - - -
karon pa ko ani nga content type.. supposed to form or text type ni, either application/x-www-form-urlencoded, multipart/form-data, or text/plain...
kung kana imo app e deploy rapud nimo kung asa ng api nabutang, pwede raka ani (for development testing): Does --disable-web-security work in Chrome anymore? - Stack Overflow
but if separate jud sila nga domain e deploy, kini:
jquery - Cross domain ajax request to a json file using JSONP - Stack Overflow
kuan nana siya if jsonp ang gamit hehehe... Nakit.an ra pud nako sa akong pag search2 ba hehehekaron pa ko ani nga content type.. supposed to form or text type ni, either application/x-www-form-urlencoded, multipart/form-data, or text/plain...
wala nalang ko nag use ug ajax guys kay murag sa ilaha jud to nga API ang problem ahahha nag curl nlang jud ko nakuha raman pud nako. Thanks for the help anyways !![]()
Similar Threads |
|