0

I have a form with three input's including image file. When i submit my form with "form action="upload.php" it works fine. But when i try to do it in ajax it shows me "THERE IS NO RESPONSE". Could anyone tell me how to do it.....?

ajax Code:

//
$('#uploadForm').submit(function(e)
{
    e.preventDefault();
    $.ajax(
    {
        url: url+'images/ajaxupload.php',
        jsonp: "callback",
        dataType: "jsonp",
        method: 'post',
        data: $('#uploadForm').serialize(),
        success: function(){
           alert('Image Uploaded');
        }

    });
}); 
//
1

1 Answer 1

1

Are you using

 enctype="multipart/form-data"

in form tag... because if you do not use this.. your file input value will not be submitted to next page...

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

3 Comments

Yes......... I found that it is a "CROSS DOMAIN (CORS)" problem....could u tell me how to resolve it.....?
There is a method in ajax "crossDomain: true"... use this and than let me know if this helps or not?
i've tried to submit my form by ajax on "on change" by calling a function "upload_image(){ ajax for submitting form }"....this also gives me cross domain error....

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.