Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

jquery - No data when attempting to get JSONP data from cross domain PHP script -


i trying pull latitude , longitude values server on different domain using singe id string. not familiar jquery, seems easiest way go getting around same origin problem. unable use iframes , cannot install php on server running javascript, forcing hand on this.

my queries appear going through properly, not getting results back. hoping here might have idea help, seeing wouldn't recognize obvious errors here.

my javascript function is:

var surl = "http://...omitted.../pull.php"; var idnum = 5a; //in practice defined above  alert("before");  $.ajax({     url: surl,     data: {id: idnum},     datatype: "jsonp",     jsonp : "callback",     jsonp: "jsonpcallback",     success: function (rdata) {         alert(rdata.lat + ", " + rdata.lon);     } });  alert("between");  function jsonpcallback(rtndata) {     alert("called");     alert(rtndata.lat + ", " + rtndata.lon); }      alert("after"); 

when javascript run, before, between , after alerts displayed. called , other jsonpcallback alerts not shown.

is there way tell if jsoncallback function has been called?

below php code have running on second server. added count table database can tell when script run. every time call javascript, count has had item inserted , id number correct.

<?php      header("content-type: application/json");  if (isset($_get['id']) || isset($_post['id'])){      $db_handle = mysql_connect($server, $username, $password);     if (!$db_handle)     {         die('could not connect: ' . mysql_error());     }      $db_found = mysql_select_db($database, $db_handle);     if ($db_found)     {         if (isset($_post['id'])){             $sql = sprintf("select * %s loc_id='%s'", $loctable, mysql_real_escape_string($_post['id']));         }          if (isset($_get['id'])){             $sql = sprintf("select * %s loc_id='%s'", $loctable, mysql_real_escape_string($_get['id']));         }         $result = mysql_query($sql, $db_handle);         $db_field = mysql_fetch_assoc($result);          $rtnjsonobj -> lat = $db_field["lat"];         $rtnjsonobj -> lon = $db_field["lon"];          if (isset($_post['id'])){             echo $_post['jsonpcallback']. '('. json_encode($rtnjsonobj) . ')';         }          if (isset($_get['id'])){             echo $_get['jsonpcallback']. '('. json_encode($rtnjsonobj) . ')';         }          $sql = sprintf("insert count (bullshit) values ('%s')", $_get['id']);         $result = mysql_query($sql, $db_handle);         $db_field = mysql_fetch_assoc($result);     }      mysql_close($db_handle); } else {     $rtnjsonobj -> lat = 404;     $rtnjsonobj -> lon = 404;     echo $_get['jsonpcallback']. '('. json_encode($rtnjsonobj) . ')'; }?> 

i not entirely sure if jsonp returned php correct. when go directly php script without including parameters, following.

 ({"lat":404,"lon":404}) 

the callback function not included, can expected when isn't included in original call.

does have idea might going wrong here?

thanks in advance!

change part of code

jsonp: "jsonpcallback", 

with:

jsonpcallback : "jsonpcallback", 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -