0

Hello i am trying to post a form data via $.post but getting the following error.enter image description here but when I run this URL manually, it works fine.

Code is:

$.post(
                    'http://dev.mydoamin/capture/' + ip + '/1',
                    $('form#frm1').serialize(),
                    function (data) {
                        var parsedJson = jQuery.parseJSON(data);
                    }
            );
baig772
  • 3,404
  • 11
  • 48
  • 93
  • Check out this SO question here: http://stackoverflow.com/questions/298745/how-do-i-send-a-cross-domain-post-request-via-javascript – Xeschylus Feb 20 '15 at 13:19
  • Or may be this link http://hayageek.com/cross-domain-ajax-request-jquery/ – Capri82 Feb 20 '15 at 13:19

1 Answers1

0

It's a Cross-domain. jQuery:

$.ajax({
     url:'http://dev.mydoamin/capture/' + ip + '/1',
     dataType: 'jsonp',
     data: $('form#frm1').serialize(),
     success:function(data){
         var parsedJson = jQuery.parseJSON(data);
     }    
});

PHP:

<?php
$arr = array("return_array");
$arr['name'] = "response";
echo $_GET['callback']."(".json_encode($arr).");";
?>
Kristiyan
  • 1,655
  • 14
  • 17