jquery - Ajax Post Error - can you see the code error? -


i trying simple ajax post working. when post headers , data url using fiddler, returns ok. ajax code goes error: function.

$(document).ready(function () {         $('#lblajaxstatus').html('ready');          $('#btnajaxlogin').click(function () {             $.ajax(            {                url: "https://www.testurl.com/api/login",                type: "post",                contenttype: "application/json",                headers: {                    "from":"cc",                    "to":"ccm",                    "language":"0",                    "offset":"-8"                },                data: { "loginid": "email@gmail.com", "password": "password1", "vehicletype": "e", "deviceid": "abcdef", "clientid": "123456", "appversion": "", "ostype": "", "osversion": "" },                success: function (data) {                    // results                    $('#lblajaxstatus').html('here ');                 },                error: function (error) {                    $('#lblajaxstatus').html('error ' + error.getresponseheader + '\n' + error.responsetext );                  }            });         }) 

i've tried set data using json.stringify( etc ), tested various desktops , changed url someplace else... results jumps error function , displays function(a){var b;if(k){if(!h){h={};while(b=eb.exec(g))h[b[1].tolowercase()]=b[2]}b=h[a.tolowercase()]}return null==b?null:b} undefined

i have no clue wrong structure or syntax? see 'error' in ways??? thanks.

replace javascript script code one

<script>     $(document).ready(function () {          $('#lblajaxstatus').html('ready');          $('#btnajaxlogin').click(function () {              $.ajax({                url: "your-ajax-file.php",                type: "post",                contenttype: "application/json",                headers: {                    "from":"cc",                    "to":"ccm",                    "language":"0",                    "offset":"-8"                },                data: { loginid: "email@gmail.com", password: "password1", vehicletype: "e", deviceid: "abcdef", clientid: "123456", appversion: "", ostype: "", osversion: "" },                success: function (data) {                    // results                    $('#lblajaxstatus').html(data);                 },                error: function (error) {                    $('#lblajaxstatus').html('error ' + error.getresponseheader + '\n' + error.responsetext );                  }            });         });     });  </script> 

your-ajax-file.php

<?php     echo "put html data here"; ?> 

i hope can you.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -