Friends urgently help remake the head broke! How to make a cross-domain query

function NotificationOmena(){ $.ajax({ url: "http://omena.kz/omenaAjax.php", dataType: "json", success: function(data) { for (var i = 0; i < data.length; i++){ var row = data[i]; if(row.rid == 1){notification_test.cancel()} function createNotificationInstance(options){ if(options.notificationType == 'simple'){ return window.webkitNotifications.createNotification( 'http://localhost/omena/icon.png','Вам ответили на сайте '+row.hostname,row.msg ); } } if(window.webkitNotifications.checkPermission() == 0) { notification_test = createNotificationInstance({notificationType: 'simple'}); notification_test.show(); } else { window.webkitNotifications.requestPermission(); } $.ajax({ type: "POST", data: "id=" + row.id, url: "/omena/hide.php", dataType: "json", success: function(data){ } }); } } }); } function OmenaSelect(){ $uid = $_SESSION['uid']; $sql = "SELECT msg,id,rid,hostname FROM msg WHERE uid='$uid' AND rid=''"; $result = $this->_db->query($sql); $data = array(); while ($row = $result->fetch_assoc()) { $data[] = $row; } echo json_encode($data); } 

    1 answer 1

    Replace

     echo json_encode($data); 

    on

     if ( preg_match("/^(?!\\d)\\w+$/", $_GET['callback']) ) { echo $_GET['callback']."(".json_encode($data).");"; } else { echo json_encode($data); }; 
    • Thank you. But the first script does not work. It gives an error. Data.length mole scolds - Sasha
    • The error has a specific text that falls into the console. - ReinRaus