amjad1233
amjad1233

Reputation: 29

Send "iframe.contents()" to PHP Script through Ajax any ideas ?

In my code I have an iFrame which loads dynamic content it's like a webpage(B.html) inside a page(A.php). in "A.php" user can edit inline the "B.html" once the process of editing has completed. In my submission I am sending iframes information to another page (script.php). I tried everything but content is not comming up in "script.php".

In nutshell, I want to tranfer my big html text with all stuff to a PHP via AJAX. I have no idea how to do it... my code would be something like below :-

Code for "A.php" inscript : "myframe" is the iframe which contains the big chunk of HTML.

sendString = $("#myframe").contents();//Tried everything here[JSON as well] 
 $.ajax({
    url: "script.php",
    type: "POST",       
    data: sendingString,    
    cache: false,
    success: function (html) { 

         return html;
    } 
});

Any help would be appreciated.

Regards, Amjad

Upvotes: 1

Views: 909

Answers (1)

Kaivosukeltaja
Kaivosukeltaja

Reputation: 15735

$("#myframe").contents() will get you it's nodes as a jQuery object. Try $("#myframe").html() instead to get the contents as a string.

EDIT: Oh, and it also helps if you fix your variable names. Change data: sendingString to data: sendString.

Upvotes: 1

Related Questions