0

Hi all you eminent StackOverflowers!

I am wondering if it is possible to call a php-script running a asp.net application using jQuery (Win7,VS2010,IIS)? Have tried some various tutorials and one setup is the one below:

My jQuery ajax-call:

$.ajax(
{
    post: "GET",
    url: "js/script.php"
}).done(function (data) {
    alert(data);
}).fail(function (jqXHR, textStatus, errorThrown) {
    alert(textStatus);
});

My Php-script:

<?php echo '<div id="test">Hello, World!</div>';?>

Calling the ajax-function just alerts the raw php-script text, i.e.

"<?php echo '<div id="test">Hello, World!</div>';?>"

And doesn't effect anything else.

What am I doing wrong? I have understood that it SHOULD be possible to run this on an asp-server.

(PS. I have looked into the suggested topics when posting this but noone have written that they get the actual php-text back DS.)

2
  • This is because you php is not getting executed .check your file path and apache .This is what I call tell you as php developer .I dont have much knowldege of asp Commented May 28, 2013 at 7:24
  • Well, I have installed PHP in the "default" folder: c:\Program Files (x86)\PHP\ and added the extension in my IIS to point to php-cgi.exe in the sam folder when running into .php-documents. Commented May 28, 2013 at 9:17

4 Answers 4

4

You cannot run PHP script on an "ASP-Server" that doesn't have PHP installed. Install PHP and everything will work.

Manual might be found on php.net.

Sign up to request clarification or add additional context in comments.

1 Comment

Well. I tried this and had my IIS point to my php-cgi.exe for *.php-modules. Didn't work any magic. Installed Wamp and got a Apacheserverrunning on my machine, and my scriptfile works when running it on that server of course, but never the less - still not working when running IIS. :(
0

You have to specify data-type into your ajax call.
If you don't see anything see into your console some error that retrieve from your call
Try this:

$.ajax(
{
    post: "GET",
    url: "js/script.php",
    dataType : 'html'
}).done(function (data) {
    alert(data);
}).fail(function (jqXHR, textStatus, errorThrown) {
    alert(textStatus);
});

3 Comments

don't use an ASP server if you would like to use PHP... Well, I don't see any problems with running php + asp | asp.NET on IIS, except some sense problems. What the problem with the server? There is no problem.
Correct the answer thanks @CORRUPT, I thinked that can create some problem.
Please, describe your suggestions better. It is appropriate, but problem not in server, but in PHP installation to the server. Thanks.
0

when you get raw php while executing php script .. it simply means that for some reasons you php is not being getting interpreted .

Check if php server is installed and configured properly

Here is some stuff that can help you

1 Comment

I dont mean apache in actual .what I meant was php server .. thanks for pointing correcting it
0
 function showState(str){
if(str.length==0){
    document.getElementById("country").innerHTML="";
    return;
}
if (typeof XMLHttpRequest != "undefined"){
  xmlHttp= new XMLHttpRequest();
  }
else if (window.ActiveXObject){
  xmlHttp= new ActiveXObject("Microsoft.XMLHTTP");
   }
  if (xmlHttp==null){
  alert("Browser does not support XMLHTTP Request");
  return;
      } 
      var url="request.php";
 url +="?count=" +str;
   xmlHttp.onreadystatechange = stateChange;
   xmlHttp.open("GET", url, true);
     xmlHttp.send(null);
    }
  function stateChange(){   
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){   
    document.getElementById("state").innerHTML=xmlHttp.responseText;   
     }   
      }
    <select name="country" id="country" onchange="showState(this.value)">
    <option value="0">ChooseProject</option>
     <c:forEach items="${al }" var="v">
        <option value="${v.projectid}">${v.projectname}</option>
         </c:forEach>
    </select>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.